Java Code Examples for net.minecraft.world.World.getEntitiesWithinAABBExcludingEntity()
The following are Jave code examples for showing how to use
getEntitiesWithinAABBExcludingEntity() of the
net.minecraft.world.World
class.
You can vote up the examples you like. Your votes will be used in our system to get
more good examples.
+ Save this method
Example 1
Project: Infernum File: SpellSoulDrain.java View Source Code | 6 votes |
@Override public void onCastTick(World world, EntityPlayer player, ItemStack stack) { if (!world.isRemote) { BlockPos centerPos = player.getPosition(); AxisAlignedBB area = new AxisAlignedBB(centerPos).expandXyz(3F); for (Entity entity : world.getEntitiesWithinAABBExcludingEntity(player, area)) { if (entity instanceof EntityLivingBase) { WorldServer worldServer = (WorldServer) world; if (player.getItemInUseCount() % 10 == 0 && consumePower(player)) { MessageSoulDrainFX message = new MessageSoulDrainFX(entity.posX, entity.posY + (entity.height / 2.0F), entity.posZ, player.posX, player.posY + (player.height / 2.0F), player.posZ); PacketHandler.INSTANCE.sendToAllAround(message, new NetworkRegistry.TargetPoint( player.dimension, player.posX, player.posY, player.posZ, 128)); entity.attackEntityFrom(DamageSource.magic, 1); world.spawnEntity(new EntityXPOrb(world, entity.posX, entity.posY + 0.5, entity.posZ, 1)); } } } } }
Example 2
Project: minecraft-quiverbow File: NetHelper.java View Source Code | 6 votes |
public static void sendTurretStateMessageToPlayersInRange(World world, Entity_AA turret, boolean hasArmor, boolean hasWeaponUpgrade, boolean hasRidingUpgrade, boolean hasPlatingUpgrade, boolean hasComUpgrade) { // Step 1, who's in range? if (world.isRemote) { return; } // Server-use only AxisAlignedBB box = turret.boundingBox.expand(64, 64, 64); List list = world.getEntitiesWithinAABBExcludingEntity(turret, box); int counter = 0; while (counter < list.size()) { Entity potentialPlayer = (Entity) list.get(counter); if (potentialPlayer instanceof EntityPlayer) { sendTurretStateMessageToPlayer((EntityPlayer) potentialPlayer, turret.getEntityId(), hasArmor, hasWeaponUpgrade, hasRidingUpgrade, hasPlatingUpgrade, hasComUpgrade); } // else, not a player. Don't care counter += 1; } }
Example 3
Project: Proyecto-DASI File: MovingTargetDecoratorImplementation.java View Source Code | 6 votes |
private boolean pinchedByPlayer(World world) { for (BlockPos bp : this.path) { //Block b = world.getBlockState(bp).getBlock(); //AxisAlignedBB aabb = b.getCollisionBoundingBox(world, bp, b.getDefaultState()); //aabb.expand(0, 1, 0); BlockPos bp2 = new BlockPos(bp.getX()+1, bp.getY()+2, bp.getZ()+1); AxisAlignedBB aabb = new AxisAlignedBB(bp, bp2); List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(null, aabb); for (Entity ent : entities) if (ent instanceof EntityPlayer) return true; } return false; }
Example 4
Project: Proyecto-DASI File: MovingTargetDecoratorImplementation.java View Source Code | 6 votes |
private boolean pinchedByPlayer(World world) { for (BlockPos bp : this.path) { //Block b = world.getBlockState(bp).getBlock(); //AxisAlignedBB aabb = b.getCollisionBoundingBox(world, bp, b.getDefaultState()); //aabb.expand(0, 1, 0); BlockPos bp2 = new BlockPos(bp.getX()+1, bp.getY()+2, bp.getZ()+1); AxisAlignedBB aabb = new AxisAlignedBB(bp, bp2); List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(null, aabb); for (Entity ent : entities) if (ent instanceof EntityPlayer) return true; } return false; }
Example 5
Project: Backmemed File: BlockPressurePlate.java View Source Code | 5 votes |
protected int computeRedstoneStrength(World worldIn, BlockPos pos) { AxisAlignedBB axisalignedbb = PRESSURE_AABB.offset(pos); List <? extends Entity > list; switch (this.sensitivity) { case EVERYTHING: list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, axisalignedbb); break; case MOBS: list = worldIn.<Entity>getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); break; default: return 0; } if (!list.isEmpty()) { for (Entity entity : list) { if (!entity.doesEntityNotTriggerPressurePlate()) { return 15; } } } return 0; }
Example 6
Project: DecompiledMinecraft File: BlockTripWire.java View Source Code | 5 votes |
private void updateState(World worldIn, BlockPos pos) { IBlockState iblockstate = worldIn.getBlockState(pos); boolean flag = ((Boolean)iblockstate.getValue(POWERED)).booleanValue(); boolean flag1 = false; List <? extends Entity > list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, new AxisAlignedBB((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)pos.getY() + this.maxY, (double)pos.getZ() + this.maxZ)); if (!list.isEmpty()) { for (Entity entity : list) { if (!entity.doesEntityNotTriggerPressurePlate()) { flag1 = true; break; } } } if (flag1 != flag) { iblockstate = iblockstate.withProperty(POWERED, Boolean.valueOf(flag1)); worldIn.setBlockState(pos, iblockstate, 3); this.notifyHook(worldIn, pos, iblockstate); } if (flag1) { worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn)); } }
Example 7
Project: uniquecrops File: GrowthSteps.java View Source Code | 5 votes |
@Override public boolean canAdvance(World world, BlockPos pos, IBlockState state) { Entity item = null, chicken = null; List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.add(-3, 0, -3), pos.add(3, 1, 3))); for (Entity ent : entities) { if (!ent.isDead) { if (ent instanceof EntityChicken) chicken = ent; if (ent instanceof EntityItem && ((EntityItem)ent).getEntityItem().getItem() == Items.BOWL) item = ent; if (item != null && chicken != null) break; } } if (chicken != null && item != null) { AxisAlignedBB aabb = new AxisAlignedBB(chicken.getPosition().add(0, 0, 0), chicken.getPosition().add(1, 1, 1)); List<Entity> list = world.getEntitiesWithinAABBExcludingEntity(chicken, aabb); for (Entity entity : list) { if (entity != null && entity == item) { EntityItem ei = new EntityItem(item.worldObj, item.posX, item.posY, item.posZ, new ItemStack(UCItems.teriyaki)); ((EntityItem)item).getEntityItem().stackSize--; if (((EntityItem)item).getEntityItem().stackSize <= 0) item.setDead(); chicken.setDead(); UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.EXPLOSION_NORMAL, chicken.posX, chicken.posY + 0.5D, chicken.posZ, 3)); if (!world.isRemote) world.spawnEntityInWorld(ei); return true; } } } else if (chicken != null) { UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.HEART, chicken.posX, chicken.posY + 1D, chicken.posZ, 3)); return true; } return false; }
Example 8
Project: BaseClient File: BlockTripWire.java View Source Code | 5 votes |
private void updateState(World worldIn, BlockPos pos) { IBlockState iblockstate = worldIn.getBlockState(pos); boolean flag = ((Boolean)iblockstate.getValue(POWERED)).booleanValue(); boolean flag1 = false; List <? extends Entity > list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, new AxisAlignedBB((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)pos.getY() + this.maxY, (double)pos.getZ() + this.maxZ)); if (!list.isEmpty()) { for (Entity entity : list) { if (!entity.doesEntityNotTriggerPressurePlate()) { flag1 = true; break; } } } if (flag1 != flag) { iblockstate = iblockstate.withProperty(POWERED, Boolean.valueOf(flag1)); worldIn.setBlockState(pos, iblockstate, 3); this.notifyHook(worldIn, pos, iblockstate); } if (flag1) { worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn)); } }
Example 9
Project: BaseClient File: BlockPressurePlate.java View Source Code | 5 votes |
protected int computeRedstoneStrength(World worldIn, BlockPos pos) { AxisAlignedBB axisalignedbb = this.getSensitiveAABB(pos); List <? extends Entity > list; switch (this.sensitivity) { case EVERYTHING: list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, axisalignedbb); break; case MOBS: list = worldIn.<Entity>getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); break; default: return 0; } if (!list.isEmpty()) { for (Entity entity : list) { if (!entity.doesEntityNotTriggerPressurePlate()) { return 15; } } } return 0; }
Example 10
Project: BaseClient File: BlockTripWire.java View Source Code | 5 votes |
private void updateState(World worldIn, BlockPos pos) { IBlockState iblockstate = worldIn.getBlockState(pos); boolean flag = ((Boolean)iblockstate.getValue(POWERED)).booleanValue(); boolean flag1 = false; List <? extends Entity > list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, new AxisAlignedBB((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)pos.getY() + this.maxY, (double)pos.getZ() + this.maxZ)); if (!list.isEmpty()) { for (Entity entity : list) { if (!entity.doesEntityNotTriggerPressurePlate()) { flag1 = true; break; } } } if (flag1 != flag) { iblockstate = iblockstate.withProperty(POWERED, Boolean.valueOf(flag1)); worldIn.setBlockState(pos, iblockstate, 3); this.notifyHook(worldIn, pos, iblockstate); } if (flag1) { worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn)); } }
Example 11
Project: Backmemed File: BlockFarmland.java View Source Code | 5 votes |
private void func_190970_b(World p_190970_1_, BlockPos p_190970_2_) { IBlockState iblockstate = Blocks.DIRT.getDefaultState(); p_190970_1_.setBlockState(p_190970_2_, iblockstate); AxisAlignedBB axisalignedbb = iblockstate.getCollisionBoundingBox(p_190970_1_, p_190970_2_).offset(p_190970_2_); for (Entity entity : p_190970_1_.getEntitiesWithinAABBExcludingEntity((Entity)null, axisalignedbb)) { entity.setPosition(entity.posX, axisalignedbb.maxY, entity.posZ); } }
Example 12
Project: Backmemed File: BlockTripWire.java View Source Code | 5 votes |
private void updateState(World worldIn, BlockPos pos) { IBlockState iblockstate = worldIn.getBlockState(pos); boolean flag = ((Boolean)iblockstate.getValue(POWERED)).booleanValue(); boolean flag1 = false; List <? extends Entity > list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, iblockstate.getBoundingBox(worldIn, pos).offset(pos)); if (!list.isEmpty()) { for (Entity entity : list) { if (!entity.doesEntityNotTriggerPressurePlate()) { flag1 = true; break; } } } if (flag1 != flag) { iblockstate = iblockstate.withProperty(POWERED, Boolean.valueOf(flag1)); worldIn.setBlockState(pos, iblockstate, 3); this.notifyHook(worldIn, pos, iblockstate); } if (flag1) { worldIn.scheduleUpdate(new BlockPos(pos), this, this.tickRate(worldIn)); } }
Example 13
Project: Backmemed File: ItemArmorStand.java View Source Code | 4 votes |
/** * 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) { if (hand == EnumFacing.DOWN) { return EnumActionResult.FAIL; } else { boolean flag = playerIn.getBlockState(worldIn).getBlock().isReplaceable(playerIn, worldIn); BlockPos blockpos = flag ? worldIn : worldIn.offset(hand); ItemStack itemstack = stack.getHeldItem(pos); if (!stack.canPlayerEdit(blockpos, hand, itemstack)) { return EnumActionResult.FAIL; } else { BlockPos blockpos1 = blockpos.up(); boolean flag1 = !playerIn.isAirBlock(blockpos) && !playerIn.getBlockState(blockpos).getBlock().isReplaceable(playerIn, blockpos); flag1 = flag1 | (!playerIn.isAirBlock(blockpos1) && !playerIn.getBlockState(blockpos1).getBlock().isReplaceable(playerIn, blockpos1)); if (flag1) { return EnumActionResult.FAIL; } else { double d0 = (double)blockpos.getX(); double d1 = (double)blockpos.getY(); double d2 = (double)blockpos.getZ(); List<Entity> list = playerIn.getEntitiesWithinAABBExcludingEntity((Entity)null, new AxisAlignedBB(d0, d1, d2, d0 + 1.0D, d1 + 2.0D, d2 + 1.0D)); if (!list.isEmpty()) { return EnumActionResult.FAIL; } else { if (!playerIn.isRemote) { playerIn.setBlockToAir(blockpos); playerIn.setBlockToAir(blockpos1); EntityArmorStand entityarmorstand = new EntityArmorStand(playerIn, d0 + 0.5D, d1, d2 + 0.5D); float f = (float)MathHelper.floor((MathHelper.wrapDegrees(stack.rotationYaw - 180.0F) + 22.5F) / 45.0F) * 45.0F; entityarmorstand.setLocationAndAngles(d0 + 0.5D, d1, d2 + 0.5D, f, 0.0F); this.applyRandomRotations(entityarmorstand, playerIn.rand); ItemMonsterPlacer.applyItemEntityDataToEntity(playerIn, stack, itemstack, entityarmorstand); playerIn.spawnEntityInWorld(entityarmorstand); playerIn.playSound((EntityPlayer)null, entityarmorstand.posX, entityarmorstand.posY, entityarmorstand.posZ, SoundEvents.ENTITY_ARMORSTAND_PLACE, SoundCategory.BLOCKS, 0.75F, 0.8F); } itemstack.func_190918_g(1); return EnumActionResult.SUCCESS; } } } } }
Example 14
Project: Backmemed File: ItemEndCrystal.java View Source Code | 4 votes |
/** * 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) { IBlockState iblockstate = playerIn.getBlockState(worldIn); if (iblockstate.getBlock() != Blocks.OBSIDIAN && iblockstate.getBlock() != Blocks.BEDROCK) { return EnumActionResult.FAIL; } else { BlockPos blockpos = worldIn.up(); ItemStack itemstack = stack.getHeldItem(pos); if (!stack.canPlayerEdit(blockpos, hand, itemstack)) { return EnumActionResult.FAIL; } else { BlockPos blockpos1 = blockpos.up(); boolean flag = !playerIn.isAirBlock(blockpos) && !playerIn.getBlockState(blockpos).getBlock().isReplaceable(playerIn, blockpos); flag = flag | (!playerIn.isAirBlock(blockpos1) && !playerIn.getBlockState(blockpos1).getBlock().isReplaceable(playerIn, blockpos1)); if (flag) { return EnumActionResult.FAIL; } else { double d0 = (double)blockpos.getX(); double d1 = (double)blockpos.getY(); double d2 = (double)blockpos.getZ(); List<Entity> list = playerIn.getEntitiesWithinAABBExcludingEntity((Entity)null, new AxisAlignedBB(d0, d1, d2, d0 + 1.0D, d1 + 2.0D, d2 + 1.0D)); if (!list.isEmpty()) { return EnumActionResult.FAIL; } else { if (!playerIn.isRemote) { EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(playerIn, (double)((float)worldIn.getX() + 0.5F), (double)(worldIn.getY() + 1), (double)((float)worldIn.getZ() + 0.5F)); entityendercrystal.setShowBottom(false); playerIn.spawnEntityInWorld(entityendercrystal); if (playerIn.provider instanceof WorldProviderEnd) { DragonFightManager dragonfightmanager = ((WorldProviderEnd)playerIn.provider).getDragonFightManager(); dragonfightmanager.respawnDragon(); } } itemstack.func_190918_g(1); return EnumActionResult.SUCCESS; } } } } }
Example 15
Project: DecompiledMinecraft File: ItemArmorStand.java View Source Code | 4 votes |
/** * 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 { boolean flag = worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos); BlockPos blockpos = flag ? pos : pos.offset(side); if (!playerIn.canPlayerEdit(blockpos, side, stack)) { return false; } else { BlockPos blockpos1 = blockpos.up(); boolean flag1 = !worldIn.isAirBlock(blockpos) && !worldIn.getBlockState(blockpos).getBlock().isReplaceable(worldIn, blockpos); flag1 = flag1 | (!worldIn.isAirBlock(blockpos1) && !worldIn.getBlockState(blockpos1).getBlock().isReplaceable(worldIn, blockpos1)); if (flag1) { return false; } else { double d0 = (double)blockpos.getX(); double d1 = (double)blockpos.getY(); double d2 = (double)blockpos.getZ(); List<Entity> list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, AxisAlignedBB.fromBounds(d0, d1, d2, d0 + 1.0D, d1 + 2.0D, d2 + 1.0D)); if (list.size() > 0) { return false; } else { if (!worldIn.isRemote) { worldIn.setBlockToAir(blockpos); worldIn.setBlockToAir(blockpos1); EntityArmorStand entityarmorstand = new EntityArmorStand(worldIn, d0 + 0.5D, d1, d2 + 0.5D); float f = (float)MathHelper.floor_float((MathHelper.wrapAngleTo180_float(playerIn.rotationYaw - 180.0F) + 22.5F) / 45.0F) * 45.0F; entityarmorstand.setLocationAndAngles(d0 + 0.5D, d1, d2 + 0.5D, f, 0.0F); this.applyRandomRotations(entityarmorstand, worldIn.rand); NBTTagCompound nbttagcompound = stack.getTagCompound(); if (nbttagcompound != null && nbttagcompound.hasKey("EntityTag", 10)) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); entityarmorstand.writeToNBTOptional(nbttagcompound1); nbttagcompound1.merge(nbttagcompound.getCompoundTag("EntityTag")); entityarmorstand.readFromNBT(nbttagcompound1); } worldIn.spawnEntityInWorld(entityarmorstand); } --stack.stackSize; return true; } } } } }
Example 16
Project: CustomWorldGen File: ItemArmorStand.java View Source Code | 4 votes |
/** * 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) { if (facing == EnumFacing.DOWN) { return EnumActionResult.FAIL; } else { boolean flag = worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos); BlockPos blockpos = flag ? pos : pos.offset(facing); if (!playerIn.canPlayerEdit(blockpos, facing, stack)) { return EnumActionResult.FAIL; } else { BlockPos blockpos1 = blockpos.up(); boolean flag1 = !worldIn.isAirBlock(blockpos) && !worldIn.getBlockState(blockpos).getBlock().isReplaceable(worldIn, blockpos); flag1 = flag1 | (!worldIn.isAirBlock(blockpos1) && !worldIn.getBlockState(blockpos1).getBlock().isReplaceable(worldIn, blockpos1)); if (flag1) { return EnumActionResult.FAIL; } else { double d0 = (double)blockpos.getX(); double d1 = (double)blockpos.getY(); double d2 = (double)blockpos.getZ(); List<Entity> list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, new AxisAlignedBB(d0, d1, d2, d0 + 1.0D, d1 + 2.0D, d2 + 1.0D)); if (!list.isEmpty()) { return EnumActionResult.FAIL; } else { if (!worldIn.isRemote) { worldIn.setBlockToAir(blockpos); worldIn.setBlockToAir(blockpos1); EntityArmorStand entityarmorstand = new EntityArmorStand(worldIn, d0 + 0.5D, d1, d2 + 0.5D); float f = (float)MathHelper.floor_float((MathHelper.wrapDegrees(playerIn.rotationYaw - 180.0F) + 22.5F) / 45.0F) * 45.0F; entityarmorstand.setLocationAndAngles(d0 + 0.5D, d1, d2 + 0.5D, f, 0.0F); this.applyRandomRotations(entityarmorstand, worldIn.rand); ItemMonsterPlacer.applyItemEntityDataToEntity(worldIn, playerIn, stack, entityarmorstand); worldIn.spawnEntityInWorld(entityarmorstand); worldIn.playSound((EntityPlayer)null, entityarmorstand.posX, entityarmorstand.posY, entityarmorstand.posZ, SoundEvents.ENTITY_ARMORSTAND_PLACE, SoundCategory.BLOCKS, 0.75F, 0.8F); } --stack.stackSize; return EnumActionResult.SUCCESS; } } } } }
Example 17
Project: BaseClient File: ItemArmorStand.java View Source Code | 4 votes |
/** * 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 { boolean flag = worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos); BlockPos blockpos = flag ? pos : pos.offset(side); if (!playerIn.canPlayerEdit(blockpos, side, stack)) { return false; } else { BlockPos blockpos1 = blockpos.up(); boolean flag1 = !worldIn.isAirBlock(blockpos) && !worldIn.getBlockState(blockpos).getBlock().isReplaceable(worldIn, blockpos); flag1 = flag1 | (!worldIn.isAirBlock(blockpos1) && !worldIn.getBlockState(blockpos1).getBlock().isReplaceable(worldIn, blockpos1)); if (flag1) { return false; } else { double d0 = (double)blockpos.getX(); double d1 = (double)blockpos.getY(); double d2 = (double)blockpos.getZ(); List<Entity> list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, AxisAlignedBB.fromBounds(d0, d1, d2, d0 + 1.0D, d1 + 2.0D, d2 + 1.0D)); if (list.size() > 0) { return false; } else { if (!worldIn.isRemote) { worldIn.setBlockToAir(blockpos); worldIn.setBlockToAir(blockpos1); EntityArmorStand entityarmorstand = new EntityArmorStand(worldIn, d0 + 0.5D, d1, d2 + 0.5D); float f = (float)MathHelper.floor_float((MathHelper.wrapAngleTo180_float(playerIn.rotationYaw - 180.0F) + 22.5F) / 45.0F) * 45.0F; entityarmorstand.setLocationAndAngles(d0 + 0.5D, d1, d2 + 0.5D, f, 0.0F); this.applyRandomRotations(entityarmorstand, worldIn.rand); NBTTagCompound nbttagcompound = stack.getTagCompound(); if (nbttagcompound != null && nbttagcompound.hasKey("EntityTag", 10)) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); entityarmorstand.writeToNBTOptional(nbttagcompound1); nbttagcompound1.merge(nbttagcompound.getCompoundTag("EntityTag")); entityarmorstand.readFromNBT(nbttagcompound1); } worldIn.spawnEntityInWorld(entityarmorstand); } --stack.stackSize; return true; } } } } }
Example 18
Project: BaseClient File: ItemArmorStand.java View Source Code | 4 votes |
/** * 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 { boolean flag = worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos); BlockPos blockpos = flag ? pos : pos.offset(side); if (!playerIn.canPlayerEdit(blockpos, side, stack)) { return false; } else { BlockPos blockpos1 = blockpos.up(); boolean flag1 = !worldIn.isAirBlock(blockpos) && !worldIn.getBlockState(blockpos).getBlock().isReplaceable(worldIn, blockpos); flag1 = flag1 | (!worldIn.isAirBlock(blockpos1) && !worldIn.getBlockState(blockpos1).getBlock().isReplaceable(worldIn, blockpos1)); if (flag1) { return false; } else { double d0 = (double)blockpos.getX(); double d1 = (double)blockpos.getY(); double d2 = (double)blockpos.getZ(); List<Entity> list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, AxisAlignedBB.fromBounds(d0, d1, d2, d0 + 1.0D, d1 + 2.0D, d2 + 1.0D)); if (list.size() > 0) { return false; } else { if (!worldIn.isRemote) { worldIn.setBlockToAir(blockpos); worldIn.setBlockToAir(blockpos1); EntityArmorStand entityarmorstand = new EntityArmorStand(worldIn, d0 + 0.5D, d1, d2 + 0.5D); float f = (float)MathHelper.floor_float((MathHelper.wrapAngleTo180_float(playerIn.rotationYaw - 180.0F) + 22.5F) / 45.0F) * 45.0F; entityarmorstand.setLocationAndAngles(d0 + 0.5D, d1, d2 + 0.5D, f, 0.0F); this.applyRandomRotations(entityarmorstand, worldIn.rand); NBTTagCompound nbttagcompound = stack.getTagCompound(); if (nbttagcompound != null && nbttagcompound.hasKey("EntityTag", 10)) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); entityarmorstand.writeToNBTOptional(nbttagcompound1); nbttagcompound1.merge(nbttagcompound.getCompoundTag("EntityTag")); entityarmorstand.readFromNBT(nbttagcompound1); } worldIn.spawnEntityInWorld(entityarmorstand); } --stack.stackSize; return true; } } } } }
Example 19
Project: CustomWorldGen File: ItemEndCrystal.java View Source Code | 4 votes |
/** * 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) { IBlockState iblockstate = worldIn.getBlockState(pos); if (iblockstate.getBlock() != Blocks.OBSIDIAN && iblockstate.getBlock() != Blocks.BEDROCK) { return EnumActionResult.FAIL; } else { BlockPos blockpos = pos.up(); if (!playerIn.canPlayerEdit(blockpos, facing, stack)) { return EnumActionResult.FAIL; } else { BlockPos blockpos1 = blockpos.up(); boolean flag = !worldIn.isAirBlock(blockpos) && !worldIn.getBlockState(blockpos).getBlock().isReplaceable(worldIn, blockpos); flag = flag | (!worldIn.isAirBlock(blockpos1) && !worldIn.getBlockState(blockpos1).getBlock().isReplaceable(worldIn, blockpos1)); if (flag) { return EnumActionResult.FAIL; } else { double d0 = (double)blockpos.getX(); double d1 = (double)blockpos.getY(); double d2 = (double)blockpos.getZ(); List<Entity> list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, new AxisAlignedBB(d0, d1, d2, d0 + 1.0D, d1 + 2.0D, d2 + 1.0D)); if (!list.isEmpty()) { return EnumActionResult.FAIL; } else { if (!worldIn.isRemote) { EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(worldIn, (double)((float)pos.getX() + 0.5F), (double)(pos.getY() + 1), (double)((float)pos.getZ() + 0.5F)); entityendercrystal.setShowBottom(false); worldIn.spawnEntityInWorld(entityendercrystal); if (worldIn.provider instanceof WorldProviderEnd) { DragonFightManager dragonfightmanager = ((WorldProviderEnd)worldIn.provider).getDragonFightManager(); dragonfightmanager.respawnDragon(); } } --stack.stackSize; return EnumActionResult.SUCCESS; } } } } }
Example 20
Project: connor41-etfuturum2 File: ItemArmourStand.java View Source Code | 4 votes |
@Override @SuppressWarnings("unchecked") public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if (side == 0) return false; else { if (side == 1) y++; if (side == 2) z--; if (side == 3) z++; if (side == 4) x--; if (side == 5) x++; if (!player.canPlayerEdit(x, y, z, side, stack)) return false; else { boolean flag1 = !world.isAirBlock(x, y, z) && !world.getBlock(x, y, z).isReplaceable(world, x, y, z); flag1 |= !world.isAirBlock(x, y + 1, z) && !world.getBlock(x, y + 1, z).isReplaceable(world, x, y + 1, z); if (flag1) return false; else { double d0 = x; double d1 = y; double d2 = z; List<Entity> list = world.getEntitiesWithinAABBExcludingEntity(null, AxisAlignedBB.getBoundingBox(d0, d1, d2, d0 + 1.0D, d1 + 2.0D, d2 + 1.0D)); if (list.size() > 0) return false; else { if (!world.isRemote) { world.setBlockToAir(x, y, z); world.setBlockToAir(x, y + 1, z); EntityArmourStand stand = new EntityArmourStand(world, d0 + 0.5D, d1, d2 + 0.5D); float f3 = MathHelper.floor_float((MathHelper.wrapAngleTo180_float(player.rotationYaw - 180.0F) + 22.5F) / 45.0F) * 45.0F; stand.setLocationAndAngles(d0 + 0.5D, d1, d2 + 0.5D, f3, 0.0F); applyRandomRotations(stand, world.rand); NBTTagCompound nbt = stack.getTagCompound(); if (nbt != null && nbt.hasKey("EntityTag", 10)) { NBTTagCompound nbt1 = new NBTTagCompound(); stand.writeToNBTOptional(nbt1); merge(nbt1, nbt.getCompoundTag("EntityTag")); stand.readFromNBT(nbt1); } world.spawnEntityInWorld(stand); } stack.stackSize--; return true; } } } } }