Java Code Examples for net.minecraft.world.World#checkNoEntityCollision()
The following examples show how to use
net.minecraft.world.World#checkNoEntityCollision() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemSlab.java From customstuff4 with GNU General Public License v3.0 | 6 votes |
private boolean tryPlace(EntityPlayer player, ItemStack stack, World worldIn, BlockPos pos, int subtype) { IBlockState iblockstate = worldIn.getBlockState(pos); if (iblockstate.getBlock() == this.singleSlab) { int subtype1 = singleSlabCS.getSubtype(iblockstate); if (subtype1 == subtype) { IBlockState stateDouble = this.makeState(subtype1); AxisAlignedBB axisalignedbb = stateDouble == null ? Block.NULL_AABB : stateDouble.getCollisionBoundingBox(worldIn, pos); if (stateDouble != null && axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) && worldIn.setBlockState(pos, stateDouble, 11)) { SoundType soundtype = stateDouble.getBlock().getSoundType(stateDouble, worldIn, pos, player); worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); stack.shrink(1); } return true; } } return false; }
Example 2
Source File: WorldOverlayRenderer.java From NotEnoughItems with MIT License | 6 votes |
private static int getSpawnMode(Chunk chunk, int x, int y, int z) { World world = chunk.getWorld(); BlockPos pos = new BlockPos(x, y, z); if (!WorldEntitySpawner.canCreatureTypeSpawnAtLocation(SpawnPlacementType.ON_GROUND, world, pos) || chunk.getLightFor(EnumSkyBlock.BLOCK, pos) >= 8) { return 0; } c.set(x + 0.2, y + 0.01, z + 0.2, x + 0.8, y + 1.8, z + 0.8); AxisAlignedBB aabb = c.aabb(); if (!world.checkNoEntityCollision(aabb) || !world.getEntitiesWithinAABBExcludingEntity(null, aabb).isEmpty() || world.containsAnyLiquid(aabb)) { return 0; } if (chunk.getLightFor(EnumSkyBlock.SKY, pos) >= 8) { return 1; } return 2; }
Example 3
Source File: ItemGenericSlab.java From Et-Futurum with The Unlicense | 6 votes |
@Override public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if (stack.stackSize == 0) return false; else if (!player.canPlayerEdit(x, y, z, side, stack)) return false; else { Block block = world.getBlock(x, y, z); int meta = world.getBlockMetadata(x, y, z); boolean flag = meta == 1; if (block == field_150939_a && (side == 1 && !flag || side == 0 && flag)) { if (world.checkNoEntityCollision(field_150939_a.getCollisionBoundingBoxFromPool(world, x, y, z)) && world.setBlock(x, y, z, field_150939_a, 2, 3)) { world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, field_150939_a.stepSound.func_150496_b(), (field_150939_a.stepSound.getVolume() + 1.0F) / 2.0F, field_150939_a.stepSound.getPitch() * 0.8F); stack.stackSize--; } return true; } else return func_150946_a(stack, player, world, x, y, z, side) ? true : super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ); } }
Example 4
Source File: WorldOverlayRenderer.java From NotEnoughItems with MIT License | 6 votes |
private static int getSpawnMode(Chunk chunk, int x, int y, int z) { World world = chunk.getWorld(); BlockPos pos = new BlockPos(x, y, z); if (!SpawnerAnimals.canCreatureTypeSpawnAtLocation(SpawnPlacementType.ON_GROUND, world, pos) || chunk.getLightFor(EnumSkyBlock.BLOCK, pos) >= 8) return 0; c.set(x+0.2, y+0.01, z+0.2, x+0.8, y+1.8, z+0.8); AxisAlignedBB aabb = c.aabb(); if (!world.checkNoEntityCollision(aabb) || !world.getCollidingBoundingBoxes(dummyEntity, aabb).isEmpty() || world.isAnyLiquid(aabb)) return 0; if (chunk.getLightFor(EnumSkyBlock.SKY, pos) >= 8) return 1; return 2; }
Example 5
Source File: ItemSlab.java From customstuff4 with GNU General Public License v3.0 | 5 votes |
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack itemstack = player.getHeldItem(hand); if (!itemstack.isEmpty() && player.canPlayerEdit(pos.offset(facing), facing, itemstack)) { int subtype = getMetadata(itemstack); IBlockState currentState = worldIn.getBlockState(pos); if (currentState.getBlock() == singleSlab) { int subtype1 = this.singleSlabCS.getSubtype(currentState); net.minecraft.block.BlockSlab.EnumBlockHalf half = currentState.getValue(net.minecraft.block.BlockSlab.HALF); if ((facing == EnumFacing.UP && half == net.minecraft.block.BlockSlab.EnumBlockHalf.BOTTOM || facing == EnumFacing.DOWN && half == net.minecraft.block.BlockSlab.EnumBlockHalf.TOP) && subtype1 == subtype) { IBlockState stateDouble = this.makeState(subtype1); AxisAlignedBB axisalignedbb = stateDouble == null ? Block.NULL_AABB : stateDouble.getCollisionBoundingBox(worldIn, pos); if (stateDouble != null && axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) && worldIn.setBlockState(pos, stateDouble, 11)) { SoundType soundtype = stateDouble.getBlock().getSoundType(stateDouble, worldIn, pos, player); worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); itemstack.shrink(1); } return EnumActionResult.SUCCESS; } } return this.tryPlace(player, itemstack, worldIn, pos.offset(facing), subtype) ? EnumActionResult.SUCCESS : super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ); } else { return EnumActionResult.FAIL; } }
Example 6
Source File: ItemGenericSlab.java From Et-Futurum with The Unlicense | 5 votes |
private boolean func_150946_a(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side) { if (side == 0) y--; if (side == 1) y++; if (side == 2) z--; if (side == 3) z++; if (side == 4) x--; if (side == 5) x++; Block block = world.getBlock(x, y, z); int meta = world.getBlockMetadata(x, y, z); if (block == field_150939_a && meta != 2) { if (world.checkNoEntityCollision(field_150939_a.getCollisionBoundingBoxFromPool(world, x, y, z)) && world.setBlockMetadataWithNotify(x, y, z, 2, 3)) { world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, field_150939_a.stepSound.func_150496_b(), (field_150939_a.stepSound.getVolume() + 1.0F) / 2.0F, field_150939_a.stepSound.getPitch() * 0.8F); stack.stackSize--; } return true; } else return false; }
Example 7
Source File: SpawnUtil.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
public static boolean isSpaceAvailableForSpawn(World worldObj, EntityLiving entity, EntityCreature asCreature, boolean checkEntityCollisions, boolean canSpawnInLiquid) { if(asCreature != null && asCreature.getBlockPathWeight(entity.getPosition()) < 0) { return false; } if(checkEntityCollisions && !worldObj.checkNoEntityCollision(entity.getEntityBoundingBox())) { return false; } if(!worldObj.getCollisionBoxes(entity, entity.getEntityBoundingBox()).isEmpty()) { return false; } if(!canSpawnInLiquid && worldObj.containsAnyLiquid(entity.getEntityBoundingBox())) { return false; } return true; }
Example 8
Source File: ItemSnow.java From customstuff4 with GNU General Public License v3.0 | 4 votes |
@Override public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack itemstack = player.getHeldItem(hand); if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack)) { IBlockState iblockstate = worldIn.getBlockState(pos); Block block = iblockstate.getBlock(); BlockPos blockpos = pos; if ((facing != EnumFacing.UP || block != this.block) && !block.isReplaceable(worldIn, pos)) { blockpos = pos.offset(facing); iblockstate = worldIn.getBlockState(blockpos); block = iblockstate.getBlock(); } if (block == this.block) { int i = iblockstate.getValue(BlockSnow.LAYERS); if (i < 8) { IBlockState iblockstate1 = iblockstate.withProperty(BlockSnow.LAYERS, i + 1); AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(worldIn, blockpos); if (axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(blockpos)) && worldIn.setBlockState(blockpos, iblockstate1, 10)) { SoundType soundtype = this.block.getSoundType(iblockstate1, worldIn, pos, player); worldIn.playSound(player, blockpos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); if (player instanceof EntityPlayerMP) { CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP)player, pos, itemstack); } itemstack.shrink(1); return EnumActionResult.SUCCESS; } } } return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ); } else { return EnumActionResult.FAIL; } }