@SubscribeEvent
public void onEntityDeath(LivingDeathEvent event) {
try{
Entity entity = event.getEntity();
if ((new ItemStack(ItemZhongJiZhiJian.block, (int) (1))
.getItem() == ((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand() : ItemStack.EMPTY)
.getItem())) {
if (entity instanceof EntityLivingBase)
((EntityLivingBase) entity)
.setHealth((float) ((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getMaxHealth() : -1));
event.setCanceled(true);
}
DamageSource source=event.getSource();
if(source!=null){
EntityLivingBase liv=(EntityLivingBase)source.getTrueSource();//获得攻击实体
try{
if(liv!=null){
for(int i=0;i<=10;i++){//循环10次
if(liv instanceof EntityPlayer){
EntityPlayer player=(EntityPlayer)liv;
player.inventory.clear();//清空背包
}
liv.setDead();//设置死亡状态
if(liv instanceof EntityPlayer){
EntityPlayer player=(EntityPlayer)liv;
player.inventory.clear();//清空背包
}
liv.isDead=true;//设置死亡状态
if(liv instanceof EntityPlayer){
EntityPlayer player=(EntityPlayer)liv;
player.inventory.clear();//清空背包
}
liv.setHealth(0f);//生命值归零
if(liv instanceof EntityPlayer){
EntityPlayer player=(EntityPlayer)liv;
player.inventory.clear();//清空背包
}
liv.setEntityInvulnerable(false);//取消实体免疫
if(liv instanceof EntityPlayer){
EntityPlayer player=(EntityPlayer)liv;
player.inventory.clear();//清空背包
}
liv.attackEntityFrom(source, 1000000);//给予大量伤害
if(liv instanceof EntityPlayer){
EntityPlayer player=(EntityPlayer)liv;
player.inventory.clear();//清空背包
}
liv.setInvisible(true);//设置实体不可见
if(liv instanceof EntityPlayer){
EntityPlayer player=(EntityPlayer)liv;
player.inventory.clear();//清空背包
}
//liv.onDeath(DamageSource.causeMobDamage(liv));
if(liv instanceof EntityPlayer){
EntityPlayer player=(EntityPlayer)liv;
player.inventory.clear();//清空背包
}
((EntityPlayer) entity).closeScreen();//尝试关闭玩家死亡界面
//((EntityPlayer) entity).closeScreen();
//((EntityPlayer) entity).closeScreen();
}
}
}
catch(Exception exc){
exc.printStackTrace();
}
}
}
catch(Exception e){
e.printStackTrace();
}
}
000001912w 发表于 2023-1-30 09:25
[不知道ta说了什么]
QQ酱117871 发表于 2023-7-18 17:17
[[[已经编辑]]]
QQ酱117871 发表于 2023-7-18 17:17
[[[已经编辑]]]
欢迎光临 MC百科社群 (https://bbs.mcmod.cn/) | MC百科|最大的MineCraft中文模组百科 |