Java Code Examples for net.minecraft.world.World#containsAnyLiquid()
The following examples show how to use
net.minecraft.world.World#containsAnyLiquid() .
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: PotionLowGrav.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void performEffect(@Nonnull EntityLivingBase entity, int amplifier) { if (!entity.isPotionActive(this)) return; double dist = -0.05; double shift = 0.175; World world = entity.world; if (world.containsAnyLiquid(entity.getEntityBoundingBox().offset(0.0, dist + shift, 0.0)) && entity.motionY < 0.5) { entity.motionY += 0.15; } else if (world.containsAnyLiquid(entity.getEntityBoundingBox().offset(0.0, dist, 0.0)) && entity.motionY < 0.0) { entity.motionY = 0.0; entity.onGround = true; } else if (world.containsAnyLiquid(entity.getEntityBoundingBox().offset(0.0, dist + entity.motionY - 0.05, 0.0)) && entity.motionY < 0.0) { entity.setPosition(entity.posX, Math.floor(entity.posY), entity.posZ); entity.motionY /= 5; entity.onGround = true; } else if (entity.motionY < 0) { entity.motionY = Math.max(entity.motionY, amplifier * -0.1); } entity.fallDistance = 0f; }
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: 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 4
Source File: TeleportHelper.java From EnderZoo with Creative Commons Zero v1.0 Universal | 4 votes |
public static boolean teleportTo(EntityLivingBase entity, double x, double y, double z, boolean fireEndermanEvent) { EnderTeleportEvent event = new EnderTeleportEvent(entity, x, y, z, 0); if (fireEndermanEvent) { if (MinecraftForge.EVENT_BUS.post(event)) { return false; } } double origX = entity.posX; double origY = entity.posY; double origZ = entity.posZ; entity.posX = event.getTargetX(); entity.posY = event.getTargetY(); entity.posZ = event.getTargetZ(); int xInt = MathHelper.floor(entity.posX); int yInt = Math.max(2, MathHelper.floor(entity.posY)); int zInt = MathHelper.floor(entity.posZ); boolean doTeleport = false; World worldObj = entity.getEntityWorld(); if (worldObj.isBlockLoaded(new BlockPos(xInt, yInt, zInt), true)) { boolean foundGround = false; while (!foundGround && yInt > 2) { IBlockState bs = worldObj.getBlockState(new BlockPos(xInt, yInt - 1, zInt)); if (bs != null && bs.getBlock() != null && bs.getMaterial().blocksMovement()) { foundGround = true; } else { --entity.posY; --yInt; } } if (foundGround) { entity.setPosition(entity.posX, entity.posY, entity.posZ); if (worldObj.getCollisionBoxes(entity, entity.getEntityBoundingBox()).isEmpty() && !worldObj.containsAnyLiquid(entity.getEntityBoundingBox())) { doTeleport = true; } else if (yInt <= 0) { doTeleport = false; } } } if (!doTeleport) { entity.setPosition(origX, origY, origZ); return false; } entity.setPositionAndUpdate(entity.posX, entity.posY, entity.posZ); short short1 = 128; for (int l = 0; l < short1; ++l) { double d6 = l / (short1 - 1.0D); float f = (rand.nextFloat() - 0.5F) * 0.2F; float f1 = (rand.nextFloat() - 0.5F) * 0.2F; float f2 = (rand.nextFloat() - 0.5F) * 0.2F; double d7 = origX + (entity.posX - origX) * d6 + (rand.nextDouble() - 0.5D) * entity.width * 2.0D; double d8 = origY + (entity.posY - origY) * d6 + rand.nextDouble() * entity.height; double d9 = origZ + (entity.posZ - origZ) * d6 + (rand.nextDouble() - 0.5D) * entity.width * 2.0D; worldObj.spawnParticle(EnumParticleTypes.PORTAL, d7, d8, d9, f, f1, f2); } worldObj.playSound(origX, origY, origZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.NEUTRAL, 1.0F, 1.0F, false); entity.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F); return true; }