• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SPacketCombatEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.minecraft.network.play.server.SPacketCombatEvent的典型用法代码示例。如果您正苦于以下问题:Java SPacketCombatEvent类的具体用法?Java SPacketCombatEvent怎么用?Java SPacketCombatEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SPacketCombatEvent类属于net.minecraft.network.play.server包,在下文中一共展示了SPacketCombatEvent类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: handleCombatEvent

import net.minecraft.network.play.server.SPacketCombatEvent; //导入依赖的package包/类
@Inject(method = "handleCombatEvent", at=  @At(value = "INVOKE_ASSIGN", target = "net/minecraft/network/PacketThreadUtil.checkThreadAndEnqueue(Lnet/minecraft/network/Packet;Lnet/minecraft/network/INetHandler;Lnet/minecraft/util/IThreadListener;)V"))
private void handleCombatEvent(SPacketCombatEvent event, CallbackInfo ci) {
    if (mc.world == null)
        return;

    if (event.eventType == SPacketCombatEvent.Event.ENTITY_DIED) {
        Entity died = mc.world.getEntityByID(event.playerId);
        Entity killer = mc.world.getEntityByID(event.entityId);

        // The entity that died should always be a player, this is just a safety measure.
        // The killer isn't checked because in some cases it can be null.
        if (died instanceof EntityPlayer)
            ClientAPI.EVENT_BUS.post(new PlayerDeathEvent((EntityPlayer) died, (EntityLivingBase) killer));
    }
}
 
开发者ID:ImpactDevelopment,项目名称:ClientAPI,代码行数:16,代码来源:MixinNetHandlerPlayClient.java


示例2: onDeath

import net.minecraft.network.play.server.SPacketCombatEvent; //导入依赖的package包/类
@Override
public void onDeath(DamageSource cause) {
	if (cause == DamageSource.OUT_OF_WORLD) {
		connection.sendPacket(new SPacketCombatEvent(getCombatTracker(), SPacketCombatEvent.Event.ENTITY_DIED, false));
		EntityLivingBase entitylivingbase = getAttackingEntity();
		if (entitylivingbase != null) {
			entitylivingbase.onItemPickup(this, scoreValue);
		}
		extinguish();
		setFlag(0, false);
		getCombatTracker().reset();
	}
}
 
开发者ID:p455w0rd,项目名称:DankNull,代码行数:14,代码来源:EntityPFakePlayer.java


示例3: handleCombatEvent

import net.minecraft.network.play.server.SPacketCombatEvent; //导入依赖的package包/类
public void handleCombatEvent(SPacketCombatEvent packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (packetIn.eventType == SPacketCombatEvent.Event.ENTITY_DIED)
    {
        Entity entity = this.clientWorldController.getEntityByID(packetIn.playerId);

        if (entity == this.gameController.player)
        {
            this.gameController.displayGuiScreen(new GuiGameOver(packetIn.deathMessage));
        }
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:15,代码来源:NetHandlerPlayClient.java


示例4: handleCombatEvent

import net.minecraft.network.play.server.SPacketCombatEvent; //导入依赖的package包/类
public void handleCombatEvent(SPacketCombatEvent packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (packetIn.eventType == SPacketCombatEvent.Event.ENTITY_DIED)
    {
        Entity entity = this.clientWorldController.getEntityByID(packetIn.playerId);

        if (entity == this.gameController.thePlayer)
        {
            this.gameController.displayGuiScreen(new GuiGameOver(packetIn.deathMessage));
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:NetHandlerPlayClient.java


示例5: onEntityDeath

import net.minecraft.network.play.server.SPacketCombatEvent; //导入依赖的package包/类
@HarshenEvent
public void onEntityDeath(LivingDeathEvent event)
{
	event.setCanceled(true);
	World world = event.getEntityLiving().world;
	if(!world.isRemote)
	{
		boolean flag = world.getGameRules().getBoolean("showDeathMessages");
		EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
		player.connection.sendPacket(new SPacketCombatEvent(player.getCombatTracker(), SPacketCombatEvent.Event.ENTITY_DIED, flag));
        if (flag)
        {
            Team team = player.getTeam();
            if (team != null && team.getDeathMessageVisibility() != Team.EnumVisible.ALWAYS)
                if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OTHER_TEAMS)
                	player.mcServer.getPlayerList().sendMessageToAllTeamMembers(player, player.getCombatTracker().getDeathMessage());
                else if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OWN_TEAM)
                	player.mcServer.getPlayerList().sendMessageToTeamOrAllPlayers(player, player.getCombatTracker().getDeathMessage());
            else
            	player.mcServer.getPlayerList().sendMessage(player.getCombatTracker().getDeathMessage());
        }

        for (ScoreObjective scoreobjective : world.getScoreboard().getObjectivesFromCriteria(IScoreCriteria.DEATH_COUNT))
            player.getWorldScoreboard().getOrCreateScore(player.getName(), scoreobjective).incrementScore();

        EntityLivingBase entitylivingbase = player.getAttackingEntity();

        if (entitylivingbase != null)
        {
            EntityList.EntityEggInfo entitylist$entityegginfo = EntityList.ENTITY_EGGS.get(EntityList.getKey(entitylivingbase));
            if (entitylist$entityegginfo != null)
            	player.addStat(entitylist$entityegginfo.entityKilledByStat);
        }
        player.addStat(StatList.DEATHS);
        player.takeStat(StatList.TIME_SINCE_DEATH);
        player.extinguish();
        HarshenUtils.setFlag(player, 0, false);
        player.getCombatTracker().reset();
        INVENTORY_MAP.put(event.getEntity().getUniqueID(), ((EntityPlayer)event.getEntity()).inventory.writeToNBT(new NBTTagList()));
        HarshenUtils.damageOccuringItemNoPacket(player, HarshenItems.SOUL_BINDING_PENDANT, 1);
        if(HarshenUtils.getFirstOccuringItem(player, HarshenItems.SOUL_BINDING_PENDANT).getItemDamage() == 
        		HarshenUtils.getFirstOccuringItem(player, HarshenItems.SOUL_BINDING_PENDANT).getMaxDamage())
        			HarshenUtils.damageOccuringItemNoPacket(player, HarshenItems.SOUL_BINDING_PENDANT, 1);    	
	}	
	new HandlerHarshenInventory().onPlayerDeath(event);
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:47,代码来源:SoulBindingPendant.java


示例6: sendEnterCombat

import net.minecraft.network.play.server.SPacketCombatEvent; //导入依赖的package包/类
/**
 * Sends an ENTER_COMBAT packet to the client
 */
public void sendEnterCombat()
{
    super.sendEnterCombat();
    this.connection.sendPacket(new SPacketCombatEvent(this.getCombatTracker(), SPacketCombatEvent.Event.ENTER_COMBAT));
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:9,代码来源:EntityPlayerMP.java


示例7: sendEndCombat

import net.minecraft.network.play.server.SPacketCombatEvent; //导入依赖的package包/类
/**
 * Sends an END_COMBAT packet to the client
 */
public void sendEndCombat()
{
    super.sendEndCombat();
    this.connection.sendPacket(new SPacketCombatEvent(this.getCombatTracker(), SPacketCombatEvent.Event.END_COMBAT));
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:9,代码来源:EntityPlayerMP.java


示例8: onDeath

import net.minecraft.network.play.server.SPacketCombatEvent; //导入依赖的package包/类
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    //-ZMod-Death---------------------------------------------------------
    ZHandle.handle("onPlayerDeath", this);
    //--------------------------------------------------------------------
 
    boolean flag = this.world.getGameRules().getBoolean("showDeathMessages");
    this.connection.sendPacket(new SPacketCombatEvent(this.getCombatTracker(), SPacketCombatEvent.Event.ENTITY_DIED, flag));

    if (flag)
    {
        Team team = this.getTeam();

        if (team != null && team.getDeathMessageVisibility() != Team.EnumVisible.ALWAYS)
        {
            if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OTHER_TEAMS)
            {
                this.mcServer.getPlayerList().sendMessageToAllTeamMembers(this, this.getCombatTracker().getDeathMessage());
            }
            else if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OWN_TEAM)
            {
                this.mcServer.getPlayerList().sendMessageToTeamOrAllPlayers(this, this.getCombatTracker().getDeathMessage());
            }
        }
        else
        {
            this.mcServer.getPlayerList().sendChatMsg(this.getCombatTracker().getDeathMessage());
        }
    }

    if (!this.world.getGameRules().getBoolean("keepInventory") && !this.isSpectator())
    {
        this.func_190776_cN();
        this.inventory.dropAllItems();
    }

    for (ScoreObjective scoreobjective : this.world.getScoreboard().getObjectivesFromCriteria(IScoreCriteria.DEATH_COUNT))
    {
        Score score = this.getWorldScoreboard().getOrCreateScore(this.getName(), scoreobjective);
        score.incrementScore();
    }

    EntityLivingBase entitylivingbase = this.getAttackingEntity();

    if (entitylivingbase != null)
    {
        EntityList.EntityEggInfo entitylist$entityegginfo = (EntityList.EntityEggInfo)EntityList.ENTITY_EGGS.get(EntityList.func_191301_a(entitylivingbase));

        if (entitylist$entityegginfo != null)
        {
            this.addStat(entitylist$entityegginfo.entityKilledByStat);
        }

        entitylivingbase.addToPlayerScore(this, this.scoreValue);
    }

    this.addStat(StatList.DEATHS);
    this.takeStat(StatList.TIME_SINCE_DEATH);
    this.extinguish();
    this.setFlag(0, false);
    this.getCombatTracker().reset();
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:66,代码来源:EntityPlayerMP.java


示例9: onDeath

import net.minecraft.network.play.server.SPacketCombatEvent; //导入依赖的package包/类
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    boolean flag = this.world.getGameRules().getBoolean("showDeathMessages");
    this.connection.sendPacket(new SPacketCombatEvent(this.getCombatTracker(), SPacketCombatEvent.Event.ENTITY_DIED, flag));

    if (flag)
    {
        Team team = this.getTeam();

        if (team != null && team.getDeathMessageVisibility() != Team.EnumVisible.ALWAYS)
        {
            if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OTHER_TEAMS)
            {
                this.mcServer.getPlayerList().sendMessageToAllTeamMembers(this, this.getCombatTracker().getDeathMessage());
            }
            else if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OWN_TEAM)
            {
                this.mcServer.getPlayerList().sendMessageToTeamOrAllPlayers(this, this.getCombatTracker().getDeathMessage());
            }
        }
        else
        {
            this.mcServer.getPlayerList().sendChatMsg(this.getCombatTracker().getDeathMessage());
        }
    }

    if (!this.world.getGameRules().getBoolean("keepInventory") && !this.isSpectator())
    {
        this.func_190776_cN();
        this.inventory.dropAllItems();
    }

    for (ScoreObjective scoreobjective : this.world.getScoreboard().getObjectivesFromCriteria(IScoreCriteria.DEATH_COUNT))
    {
        Score score = this.getWorldScoreboard().getOrCreateScore(this.getName(), scoreobjective);
        score.incrementScore();
    }

    EntityLivingBase entitylivingbase = this.getAttackingEntity();

    if (entitylivingbase != null)
    {
        EntityList.EntityEggInfo entitylist$entityegginfo = (EntityList.EntityEggInfo)EntityList.ENTITY_EGGS.get(EntityList.func_191301_a(entitylivingbase));

        if (entitylist$entityegginfo != null)
        {
            this.addStat(entitylist$entityegginfo.entityKilledByStat);
        }

        entitylivingbase.addToPlayerScore(this, this.scoreValue);
    }

    this.addStat(StatList.DEATHS);
    this.takeStat(StatList.TIME_SINCE_DEATH);
    this.extinguish();
    this.setFlag(0, false);
    this.getCombatTracker().reset();
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:62,代码来源:EntityPlayerMP.java


示例10: onDeath

import net.minecraft.network.play.server.SPacketCombatEvent; //导入依赖的package包/类
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, cause)) return;
    boolean flag = this.worldObj.getGameRules().getBoolean("showDeathMessages");
    this.connection.sendPacket(new SPacketCombatEvent(this.getCombatTracker(), SPacketCombatEvent.Event.ENTITY_DIED, flag));

    if (flag)
    {
        Team team = this.getTeam();

        if (team != null && team.getDeathMessageVisibility() != Team.EnumVisible.ALWAYS)
        {
            if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OTHER_TEAMS)
            {
                this.mcServer.getPlayerList().sendMessageToAllTeamMembers(this, this.getCombatTracker().getDeathMessage());
            }
            else if (team.getDeathMessageVisibility() == Team.EnumVisible.HIDE_FOR_OWN_TEAM)
            {
                this.mcServer.getPlayerList().sendMessageToTeamOrAllPlayers(this, this.getCombatTracker().getDeathMessage());
            }
        }
        else
        {
            this.mcServer.getPlayerList().sendChatMsg(this.getCombatTracker().getDeathMessage());
        }
    }

    if (!this.worldObj.getGameRules().getBoolean("keepInventory") && !this.isSpectator())
    {
        captureDrops = true;
        capturedDrops.clear();

        this.inventory.dropAllItems();

        captureDrops = false;
        net.minecraftforge.event.entity.player.PlayerDropsEvent event = new net.minecraftforge.event.entity.player.PlayerDropsEvent(this, cause, capturedDrops, recentlyHit > 0);
        if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event))
        {
            for (net.minecraft.entity.item.EntityItem item : capturedDrops)
            {
                this.worldObj.spawnEntityInWorld(item);
            }
        }
    }

    for (ScoreObjective scoreobjective : this.worldObj.getScoreboard().getObjectivesFromCriteria(IScoreCriteria.DEATH_COUNT))
    {
        Score score = this.getWorldScoreboard().getOrCreateScore(this.getName(), scoreobjective);
        score.incrementScore();
    }

    EntityLivingBase entitylivingbase = this.getAttackingEntity();

    if (entitylivingbase != null)
    {
        EntityList.EntityEggInfo entitylist$entityegginfo = (EntityList.EntityEggInfo)EntityList.ENTITY_EGGS.get(EntityList.getEntityString(entitylivingbase));

        if (entitylist$entityegginfo != null)
        {
            this.addStat(entitylist$entityegginfo.entityKilledByStat);
        }

        entitylivingbase.addToPlayerScore(this, this.scoreValue);
    }

    this.addStat(StatList.DEATHS);
    this.takeStat(StatList.TIME_SINCE_DEATH);
    this.getCombatTracker().reset();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:73,代码来源:EntityPlayerMP.java


示例11: handleCombatEvent

import net.minecraft.network.play.server.SPacketCombatEvent; //导入依赖的package包/类
void handleCombatEvent(SPacketCombatEvent packetIn); 
开发者ID:sudofox,项目名称:Backmemed,代码行数:2,代码来源:INetHandlerPlayClient.java



注:本文中的net.minecraft.network.play.server.SPacketCombatEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TrackElement类代码示例发布时间:2022-05-23
下一篇:
Java RxBleClient类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap