public static void moveEntityDefault(Entity entity, BlockPos dist) { if (entity instanceof EntityHanging) { EntityHanging entityHanging = (EntityHanging) entity; BlockPos hangingPosition = entityHanging.getHangingPosition().add(dist); entityHanging.setPosition(hangingPosition.getX(), hangingPosition.getY(), hangingPosition.getZ()); } else { entity.setPosition(entity.posX + dist.getX(), entity.posY + dist.getY(), entity.posZ + dist.getZ()); } if (entity instanceof EntityCreature) { EntityCreature entityCreature = (EntityCreature) entity; EntityCreatureAccessor.setHomePosition(entityCreature, entityCreature.getHomePosition().add(dist)); } }
public static void moveEntityForGeneration(Entity entity, BlockCoord coord) { if (entity instanceof Movable) ((Movable) entity).move(coord.x, coord.y, coord.z); else { entity.setPosition(entity.posX + coord.x, entity.posY + coord.y, entity.posZ + coord.z); if (entity instanceof EntityHanging) { EntityHanging entityHanging = (EntityHanging) entity; entityHanging.field_146063_b += coord.x; entityHanging.field_146064_c += coord.y; entityHanging.field_146062_d += coord.z; entityHanging.setDirection(entityHanging.hangingDirection); } } }
public static void transformEntityPosForGeneration(Entity entity, AxisAlignedTransform2D transform, int[] size) { if (entity instanceof Transformable) ((Transformable) entity).transform(transform.getRotation(), transform.isMirrorX(), size); else { double[] newEntityPos = transform.apply(new double[]{entity.posX, entity.posY, entity.posZ}, size); entity.setPosition(newEntityPos[0], newEntityPos[1], newEntityPos[2]); if (entity instanceof EntityHanging) { EntityHanging entityHanging = (EntityHanging) entity; BlockCoord hangingCoord = new BlockCoord(entityHanging.field_146063_b, entityHanging.field_146064_c, entityHanging.field_146062_d); BlockCoord newHangingCoord = transform.apply(hangingCoord, size); entityHanging.field_146063_b = newHangingCoord.x; entityHanging.field_146064_c = newHangingCoord.y; entityHanging.field_146062_d = newHangingCoord.z; entityHanging.setDirection(entityHanging.hangingDirection); } } }
public boolean func_77648_a(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { if(p_77648_7_ == 0) { return false; } else if(p_77648_7_ == 1) { return false; } else { int var11 = Direction.field_71579_d[p_77648_7_]; EntityHanging var12 = this.func_82810_a(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, var11); if(!p_77648_2_.func_82247_a(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_)) { return false; } else { if(var12 != null && var12.func_70518_d()) { if(!p_77648_3_.field_72995_K) { p_77648_3_.func_72838_d(var12); } --p_77648_1_.field_77994_a; } return true; } } }
/** * Called when a Block is right-clicked with this Item */ public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { if (side == EnumFacing.DOWN) { return false; } else if (side == EnumFacing.UP) { return false; } else { BlockPos blockpos = pos.offset(side); if (!playerIn.canPlayerEdit(blockpos, side, stack)) { return false; } else { EntityHanging entityhanging = this.createEntity(worldIn, blockpos, side); if (entityhanging != null && entityhanging.onValidSurface()) { if (!worldIn.isRemote) { worldIn.spawnEntityInWorld(entityhanging); } --stack.stackSize; } return true; } } }
/** * Called when a Block is right-clicked with this Item */ public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY) { ItemStack itemstack = stack.getHeldItem(pos); BlockPos blockpos = worldIn.offset(hand); if (hand != EnumFacing.DOWN && hand != EnumFacing.UP && stack.canPlayerEdit(blockpos, hand, itemstack)) { EntityHanging entityhanging = this.createEntity(playerIn, blockpos, hand); if (entityhanging != null && entityhanging.onValidSurface()) { if (!playerIn.isRemote) { entityhanging.playPlaceSound(); playerIn.spawnEntityInWorld(entityhanging); } itemstack.func_190918_g(1); } return EnumActionResult.SUCCESS; } else { return EnumActionResult.FAIL; } }
/** * Called when a Block is right-clicked with this Item */ public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { BlockPos blockpos = pos.offset(facing); if (facing != EnumFacing.DOWN && facing != EnumFacing.UP && playerIn.canPlayerEdit(blockpos, facing, stack)) { EntityHanging entityhanging = this.createEntity(worldIn, blockpos, facing); if (entityhanging != null && entityhanging.onValidSurface()) { if (!worldIn.isRemote) { entityhanging.playPlaceSound(); worldIn.spawnEntityInWorld(entityhanging); } --stack.stackSize; } return EnumActionResult.SUCCESS; } else { return EnumActionResult.FAIL; } }
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack itemstack = player.getHeldItem(hand); BlockPos blockpos = pos.offset(facing); if (facing != EnumFacing.DOWN && facing != EnumFacing.UP && player.canPlayerEdit(blockpos, facing, itemstack)) { EntityHanging entityhanging = this.createEntity(worldIn, blockpos, facing); if (entityhanging != null && entityhanging.onValidSurface()) { if (!worldIn.isRemote) { entityhanging.playPlaceSound(); worldIn.spawnEntity(entityhanging); } itemstack.shrink(1); } return EnumActionResult.SUCCESS; } else { return EnumActionResult.FAIL; } }
private static void updateEntityHangingBoundingBox (EntityHanging entity) { double d0 = (double)entity.getHangingPosition().getX() + 0.5D; double d1 = (double)entity.getHangingPosition().getY() + 0.5D; double d2 = (double)entity.getHangingPosition().getZ() + 0.5D; double d3 = 0.46875D; double d4 = entity.getWidthPixels() % 32 == 0 ? 0.5D : 0.0D;; double d5 = entity.getHeightPixels() % 32 == 0 ? 0.5D : 0.0D;; d0 = d0 - (double)entity.facingDirection.getFrontOffsetX() * 0.46875D; d2 = d2 - (double)entity.facingDirection.getFrontOffsetZ() * 0.46875D; d1 = d1 + d5; EnumFacing enumfacing = entity.facingDirection.rotateYCCW(); d0 = d0 + d4 * (double)enumfacing.getFrontOffsetX(); d2 = d2 + d4 * (double)enumfacing.getFrontOffsetZ(); entity.posX = d0; entity.posY = d1; entity.posZ = d2; double d6 = (double)entity.getWidthPixels(); double d7 = (double)entity.getHeightPixels(); double d8 = (double)entity.getWidthPixels(); if (entity.facingDirection.getAxis() == EnumFacing.Axis.Z) { d8 = 1.0D; } else { d6 = 1.0D; } d6 = d6 / 32.0D; d7 = d7 / 32.0D; d8 = d8 / 32.0D; entity.setEntityBoundingBox(new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8)); }
/** * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return * True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { if (p_77648_7_ == 0) { return false; } else if (p_77648_7_ == 1) { return false; } else { int i1 = Direction.facingToDirection[p_77648_7_]; EntityHanging entityhanging = this.createHangingEntity(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, i1); if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_)) { return false; } else { if (entityhanging != null && entityhanging.onValidSurface()) { if (!p_77648_3_.isRemote) { p_77648_3_.spawnEntityInWorld(entityhanging); } --p_77648_1_.stackSize; } return true; } } }
/** * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return * True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (par7 == 0) { return false; } else if (par7 == 1) { return false; } else { int var11 = Direction.facingToDirection[par7]; EntityHanging var12 = this.createHangingEntity(par3World, par4, par5, par6, var11); if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) { return false; } else { if (var12 != null && var12.onValidSurface()) { if (!par3World.isClient) { par3World.spawnEntityInWorld(var12); } --par1ItemStack.stackSize; } return true; } } }
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { if (p_77648_7_ == 0) { return false; } else if (p_77648_7_ == 1) { return false; } else { int i1 = Direction.facingToDirection[p_77648_7_]; EntityHanging entityhanging = this.createHangingEntity(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, i1); if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_)) { return false; } else { if (entityhanging != null && entityhanging.onValidSurface()) { if (!p_77648_3_.isRemote) { p_77648_3_.spawnEntityInWorld(entityhanging); } --p_77648_1_.stackSize; } return true; } } }
/** * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return * True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (par7 == 0) { return false; } else if (par7 == 1) { return false; } else { int i1 = Direction.facingToDirection[par7]; EntityHanging entityhanging = this.createHangingEntity(par3World, par4, par5, par6, i1); if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) { return false; } else { if (entityhanging != null && entityhanging.onValidSurface()) { if (!par3World.isRemote) { par3World.spawnEntityInWorld(entityhanging); } --par1ItemStack.stackSize; } return true; } } }
public ItemHangingEntity(Class <? extends EntityHanging > entityClass) { this.hangingEntityClass = entityClass; this.setCreativeTab(CreativeTabs.tabDecorations); }
private EntityHanging createEntity(World worldIn, BlockPos pos, EnumFacing clickedSide) { return (EntityHanging)(this.hangingEntityClass == EntityPainting.class ? new EntityPainting(worldIn, pos, clickedSide) : (this.hangingEntityClass == EntityItemFrame.class ? new EntityItemFrame(worldIn, pos, clickedSide) : null)); }
public ItemHangingEntity(Class <? extends EntityHanging > entityClass) { this.hangingEntityClass = entityClass; this.setCreativeTab(CreativeTabs.DECORATIONS); }
@Nullable private EntityHanging createEntity(World worldIn, BlockPos pos, EnumFacing clickedSide) { return (EntityHanging)(this.hangingEntityClass == EntityPainting.class ? new EntityPainting(worldIn, pos, clickedSide) : (this.hangingEntityClass == EntityItemFrame.class ? new EntityItemFrame(worldIn, pos, clickedSide) : null)); }
private EntityHanging createEntity(World worldIn, BlockPos pos, EnumFacing clickedSide) { return new EntityArtifactFrame(worldIn, pos, clickedSide); }
/** * Create the hanging entity associated to this item. */ private EntityHanging createHangingEntity(World p_82810_1_, int p_82810_2_, int p_82810_3_, int p_82810_4_, int p_82810_5_) { return (EntityHanging)(this.hangingEntityClass == EntityEpicProportionsPainting.class ? new EntityEpicProportionsPainting(p_82810_1_, p_82810_2_, p_82810_3_, p_82810_4_, p_82810_5_) : (this.hangingEntityClass == EntityItemFrame.class ? new EntityItemFrame(p_82810_1_, p_82810_2_, p_82810_3_, p_82810_4_, p_82810_5_) : null)); }
/** * Create the hanging entity associated to this item. */ private EntityHanging createHangingEntity(World par1World, int par2, int par3, int par4, int par5) { return (EntityHanging)(this.hangingEntityClass == EntityPainting.class ? new EntityPainting(par1World, par2, par3, par4, par5) : (this.hangingEntityClass == EntityItemFrame.class ? new EntityItemFrame(par1World, par2, par3, par4, par5) : null)); }
private EntityHanging createHangingEntity(World p_82810_1_, int p_82810_2_, int p_82810_3_, int p_82810_4_, int p_82810_5_) { return (EntityHanging)(this.hangingEntityClass == EntityPainting.class ? new EntityPainting(p_82810_1_, p_82810_2_, p_82810_3_, p_82810_4_, p_82810_5_) : (this.hangingEntityClass == EntityItemFrame.class ? new EntityItemFrame(p_82810_1_, p_82810_2_, p_82810_3_, p_82810_4_, p_82810_5_) : null)); }
public void func_70014_b(NBTTagCompound p_70014_1_) { super.func_70014_b(p_70014_1_); p_70014_1_.func_74757_a("CanPickUpLoot", this.func_98052_bS()); p_70014_1_.func_74757_a("PersistenceRequired", this.field_82179_bU); NBTTagList var2 = new NBTTagList(); NBTTagCompound var4; for(int var3 = 0; var3 < this.field_82182_bS.length; ++var3) { var4 = new NBTTagCompound(); if(this.field_82182_bS[var3] != null) { this.field_82182_bS[var3].func_77955_b(var4); } var2.func_74742_a(var4); } p_70014_1_.func_74782_a("Equipment", var2); NBTTagList var6 = new NBTTagList(); for(int var7 = 0; var7 < this.field_82174_bp.length; ++var7) { var6.func_74742_a(new NBTTagFloat(var7 + "", this.field_82174_bp[var7])); } p_70014_1_.func_74782_a("DropChances", var6); p_70014_1_.func_74778_a("CustomName", this.func_94057_bL()); p_70014_1_.func_74757_a("CustomNameVisible", this.func_94062_bN()); p_70014_1_.func_74757_a("Leashed", this.field_110169_bv); if(this.field_110168_bw != null) { var4 = new NBTTagCompound("Leash"); if(this.field_110168_bw instanceof EntityLivingBase) { var4.func_74772_a("UUIDMost", this.field_110168_bw.func_110124_au().getMostSignificantBits()); var4.func_74772_a("UUIDLeast", this.field_110168_bw.func_110124_au().getLeastSignificantBits()); } else if(this.field_110168_bw instanceof EntityHanging) { EntityHanging var5 = (EntityHanging)this.field_110168_bw; var4.func_74768_a("X", var5.field_70523_b); var4.func_74768_a("Y", var5.field_70524_c); var4.func_74768_a("Z", var5.field_70521_d); } p_70014_1_.func_74782_a("Leash", var4); } }
public void func_72786_a(Entity p_72786_1_) { if(p_72786_1_ instanceof EntityPlayerMP) { this.func_72791_a(p_72786_1_, 512, 2); EntityPlayerMP var2 = (EntityPlayerMP)p_72786_1_; Iterator var3 = this.field_72793_b.iterator(); while(var3.hasNext()) { EntityTrackerEntry var4 = (EntityTrackerEntry)var3.next(); if(var4.field_73132_a != var2) { var4.func_73117_b(var2); } } } else if(p_72786_1_ instanceof EntityFishHook) { this.func_72785_a(p_72786_1_, 64, 5, true); } else if(p_72786_1_ instanceof EntityArrow) { this.func_72785_a(p_72786_1_, 64, 20, false); } else if(p_72786_1_ instanceof EntitySmallFireball) { this.func_72785_a(p_72786_1_, 64, 10, false); } else if(p_72786_1_ instanceof EntityFireball) { this.func_72785_a(p_72786_1_, 64, 10, false); } else if(p_72786_1_ instanceof EntitySnowball) { this.func_72785_a(p_72786_1_, 64, 10, true); } else if(p_72786_1_ instanceof EntityEnderPearl) { this.func_72785_a(p_72786_1_, 64, 10, true); } else if(p_72786_1_ instanceof EntityEnderEye) { this.func_72785_a(p_72786_1_, 64, 4, true); } else if(p_72786_1_ instanceof EntityEgg) { this.func_72785_a(p_72786_1_, 64, 10, true); } else if(p_72786_1_ instanceof EntityPotion) { this.func_72785_a(p_72786_1_, 64, 10, true); } else if(p_72786_1_ instanceof EntityExpBottle) { this.func_72785_a(p_72786_1_, 64, 10, true); } else if(p_72786_1_ instanceof EntityFireworkRocket) { this.func_72785_a(p_72786_1_, 64, 10, true); } else if(p_72786_1_ instanceof EntityItem) { this.func_72785_a(p_72786_1_, 64, 20, true); } else if(p_72786_1_ instanceof EntityMinecart) { this.func_72785_a(p_72786_1_, 80, 3, true); } else if(p_72786_1_ instanceof EntityBoat) { this.func_72785_a(p_72786_1_, 80, 3, true); } else if(p_72786_1_ instanceof EntitySquid) { this.func_72785_a(p_72786_1_, 64, 3, true); } else if(p_72786_1_ instanceof EntityWither) { this.func_72785_a(p_72786_1_, 80, 3, false); } else if(p_72786_1_ instanceof EntityBat) { this.func_72785_a(p_72786_1_, 80, 3, false); } else if(p_72786_1_ instanceof IAnimals) { this.func_72785_a(p_72786_1_, 80, 3, true); } else if(p_72786_1_ instanceof EntityDragon) { this.func_72785_a(p_72786_1_, 160, 3, true); } else if(p_72786_1_ instanceof EntityTNTPrimed) { this.func_72785_a(p_72786_1_, 160, 10, true); } else if(p_72786_1_ instanceof EntityFallingSand) { this.func_72785_a(p_72786_1_, 160, 20, true); } else if(p_72786_1_ instanceof EntityHanging) { this.func_72785_a(p_72786_1_, 160, Integer.MAX_VALUE, false); } else if(p_72786_1_ instanceof EntityXPOrb) { this.func_72785_a(p_72786_1_, 160, 20, true); } else if(p_72786_1_ instanceof EntityEnderCrystal) { this.func_72785_a(p_72786_1_, 256, Integer.MAX_VALUE, false); } }
private EntityHanging func_82810_a(World p_82810_1_, int p_82810_2_, int p_82810_3_, int p_82810_4_, int p_82810_5_) { return (EntityHanging)(this.field_82811_a == EntityPainting.class?new EntityPainting(p_82810_1_, p_82810_2_, p_82810_3_, p_82810_4_, p_82810_5_):(this.field_82811_a == EntityItemFrame.class?new EntityItemFrame(p_82810_1_, p_82810_2_, p_82810_3_, p_82810_4_, p_82810_5_):null)); }