fixed reviving trait not works with wither skeletons, closes #32

This commit is contained in:
2016-10-18 20:57:03 +02:00
parent ae4aef454e
commit ea594cef3d

View File

@@ -5,6 +5,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -36,10 +37,16 @@ public class TraitReviving extends AbstractTrait {
if (e.getSource().getEntity() instanceof EntityPlayer && e.getEntity() instanceof EntityCreature) { if (e.getSource().getEntity() instanceof EntityPlayer && e.getEntity() instanceof EntityCreature) {
if (isNight((int) w.getWorldTime()) && random.nextFloat() > 0.85 && TinkerUtil.hasTrait(TagUtil.getTagSafe(((EntityPlayer) e.getSource().getEntity()).getHeldItemMainhand()), identifier)) { if (isNight((int) w.getWorldTime()) && random.nextFloat() > 0.85 && TinkerUtil.hasTrait(TagUtil.getTagSafe(((EntityPlayer) e.getSource().getEntity()).getHeldItemMainhand()), identifier)) {
String name = EntityList.getEntityString(e.getEntity()); String name = EntityList.getEntityString(e.getEntity());
Entity ent = EntityList.createEntityByName(name, w); Entity ent = EntityList.createEntityByName(name, w);
assert ent != null; if (ent != null) {
ent.setPosition(pos.getX(), pos.getY(), pos.getZ()); if (ent instanceof EntitySkeleton && e.getEntity() instanceof EntitySkeleton) {
w.spawnEntityInWorld(ent); ((EntitySkeleton) ent).setSkeletonType(((EntitySkeleton) e.getEntity()).getSkeletonType());
}
ent.setPosition(pos.getX(), pos.getY(), pos.getZ());
w.spawnEntityInWorld(ent);
}
} }
} }
} }