Java Code Examples for net.minecraft.entity.Entity#isInWater()
The following examples show how to use
net.minecraft.entity.Entity#isInWater() .
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: ModelTofuFish.java From TofuCraftReload with MIT License | 5 votes |
/** * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how "far" * arms and legs can swing at most. */ public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { float f = 1.0F; if (!entityIn.isInWater()) { f = 1.5F; } this.field_203729_g.rotateAngleY = -f * 0.45F * MathHelper.sin(0.6F * ageInTicks); }
Example 2
Source File: MoCEntityFishy.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
@Override protected void attackEntity(Entity entity, float f) { if (attackTime <= 0 && (f < 2D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY)) { if (entity.isInWater() || (entity instanceof EntityPlayer && ((EntityPlayer)entity).ridingEntity == null)) { attackTime = 20; entity.attackEntityFrom(DamageSource.causeMobDamage(this), 1); } } }
Example 3
Source File: PathFinderDrone.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
/** * Internal implementation of creating a path from an entity to a point */ private PathEntity createEntityPathTo(Entity par1Entity, double par2, double par4, double par6, float par8){ path.clearPath(); pointMap.clearMap(); boolean flag = isPathingInWater; int i = MathHelper.floor_double(par1Entity.boundingBox.minY + 0.5D); if(canEntityDrown && par1Entity.isInWater()) { i = (int)par1Entity.boundingBox.minY; for(Block j = worldMap.getBlock(MathHelper.floor_double(par1Entity.posX), i, MathHelper.floor_double(par1Entity.posZ)); j == Blocks.water || j == Blocks.flowing_water; j = worldMap.getBlock(MathHelper.floor_double(par1Entity.posX), i, MathHelper.floor_double(par1Entity.posZ))) { ++i; } flag = isPathingInWater; isPathingInWater = false; } else { i = MathHelper.floor_double(par1Entity.boundingBox.minY + 0.5D); } PathPoint pathpoint = openPoint(MathHelper.floor_double(par1Entity.boundingBox.minX), i, MathHelper.floor_double(par1Entity.boundingBox.minZ)); PathPoint pathpoint1 = openPoint(MathHelper.floor_double(par2 - par1Entity.width / 2.0F), MathHelper.floor_double(par4), MathHelper.floor_double(par6 - par1Entity.width / 2.0F)); PathPoint pathpoint2 = new PathPoint(MathHelper.floor_float(par1Entity.width + 1.0F), MathHelper.floor_float(par1Entity.height + 1.0F), MathHelper.floor_float(par1Entity.width + 1.0F)); PathEntity pathentity = addToPath(par1Entity, pathpoint, pathpoint1, pathpoint2, par8); isPathingInWater = flag; return pathentity; }
Example 4
Source File: GravityHandler.java From AdvancedRocketry with MIT License | 4 votes |
public static void applyGravity(Entity entity) { if(entity.hasNoGravity()) return; if(!entity.isInWater() || entity instanceof EntityItem) { if(!(entity instanceof EntityPlayer) || !((EntityPlayer)entity).capabilities.isFlying) { Double d; if(entityMap.containsKey(entity) && (d = entityMap.get(entity)) != null) { double multiplier = (entity instanceof EntityItem) ? ITEM_GRAV_OFFSET*d : 0.075f*d; entity.motionY += multiplier; } else if(DimensionManager.getInstance().isDimensionCreated(entity.world.provider.getDimension()) || entity.world.provider instanceof WorldProviderSpace) { double gravMult; if(entity.world.provider instanceof IPlanetaryProvider) gravMult = ((IPlanetaryProvider)entity.world.provider).getGravitationalMultiplier(entity.getPosition()); else gravMult = DimensionManager.getInstance().getDimensionProperties(entity.world.provider.getDimension()).gravitationalMultiplier; if(entity instanceof EntityItem) entity.motionY -= gravMult*ITEM_GRAV_OFFSET; else//Not-Items are not ASMed, so they have to subtract the original gravity. entity.motionY -= (gravMult*ENTITY_OFFSET - ENTITY_OFFSET); return; } else { //GC handling if(gcWorldProvider != null && gcWorldProvider.isAssignableFrom(entity.world.provider.getClass())) { try { entity.motionY -= 0.075f - (float)gcGetGravity.invoke(entity.world.provider); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } } else { if(entity instanceof EntityItem) entity.motionY -= ITEM_GRAV_OFFSET; //else//Without the ASM, this added extra gravity in overworld on SMP //entity.motionY -= 0.005d; } } } } }
Example 5
Source File: ClientTickHandler.java From SimplyJetpacks with MIT License | 4 votes |
private static void tickEnd() { if (mc.thePlayer == null || mc.theWorld == null) { return; } if (!mc.isGamePaused()) { Iterator<Integer> itr = SyncHandler.getJetpackStates().keySet().iterator(); int currentEntity; while (itr.hasNext()) { currentEntity = itr.next(); Entity entity = mc.theWorld.getEntityByID(currentEntity); if (entity == null || !(entity instanceof EntityLivingBase) || entity.dimension != mc.thePlayer.dimension) { itr.remove(); } else { ParticleType particle = SyncHandler.getJetpackStates().get(currentEntity); if (particle != null) { if (entity.isInWater() && particle != ParticleType.NONE) { particle = ParticleType.BUBBLE; } SimplyJetpacks.proxy.showJetpackParticles(mc.theWorld, (EntityLivingBase) entity, particle); if (Config.jetpackSounds && !SoundJetpack.isPlayingFor(entity.getEntityId())) { Minecraft.getMinecraft().getSoundHandler().playSound(new SoundJetpack((EntityLivingBase) entity)); } } else { itr.remove(); } } } } if (sprintKeyCheck && mc.thePlayer.movementInput.moveForward < 1.0F) { sprintKeyCheck = false; } if (!Config.doubleTapSprintInAir || !wearingJetpack || mc.thePlayer.onGround || mc.thePlayer.isSprinting() || mc.thePlayer.isUsingItem() || mc.thePlayer.isPotionActive(Potion.blindness)) { return; } if (!sprintKeyCheck && mc.thePlayer.movementInput.moveForward >= 1.0F && !mc.thePlayer.isCollidedHorizontally && (mc.thePlayer.getFoodStats().getFoodLevel() > 6.0F || mc.thePlayer.capabilities.allowFlying)) { if (mc.thePlayer.sprintToggleTimer <= 0 && !mc.gameSettings.keyBindSprint.getIsKeyPressed()) { mc.thePlayer.sprintToggleTimer = 7; sprintKeyCheck = true; } else { mc.thePlayer.setSprinting(true); } } }