@SubscribeEvent public void onAddCollisionBox(AddCollisionBoxToListEvent event) { if (getLocalPlayer() != null && (event.getBlock() instanceof BlockLiquid) && (EntityUtils.isDrivenByPlayer(event.getEntity()) || EntityUtils.isLocalPlayer(event.getEntity())) && !(event.getEntity() instanceof EntityBoat) && !getLocalPlayer().isSneaking() && getLocalPlayer().fallDistance < 3 && !isInWater(getLocalPlayer()) && (isAboveWater(getLocalPlayer(), false) || isAboveWater(getRidingEntity(), false)) && isAboveBlock(getLocalPlayer(), event.getPos())) { AxisAlignedBB axisalignedbb = WATER_WALK_AA.offset(event.getPos()); if (event.getEntityBox().intersects(axisalignedbb)) event.getCollidingBoxes().add(axisalignedbb); // cancel event, which will stop it from calling the original code event.setCanceled(true); } }
public boolean startRiding(Entity entityIn, boolean force) { if (!super.startRiding(entityIn, force)) { return false; } else { if (entityIn instanceof EntityMinecart) { this.mc.getSoundHandler().playSound(new MovingSoundMinecartRiding(this, (EntityMinecart)entityIn)); } if (entityIn instanceof EntityBoat) { this.prevRotationYaw = entityIn.rotationYaw; this.rotationYaw = entityIn.rotationYaw; this.setRotationYawHead(entityIn.rotationYaw); } return true; } }
/** * Called to update the entity's position/logic. */ public void onUpdate() { if (Config.isSmoothWorld() && this.canSkipUpdate()) { this.onUpdateMinimal(); } else { super.onUpdate(); if (!this.world.isRemote) { this.updateLeashedState(); if (this.ticksExisted % 5 == 0) { boolean flag = !(this.getControllingPassenger() instanceof EntityLiving); boolean flag1 = !(this.getRidingEntity() instanceof EntityBoat); this.tasks.setControlFlag(1, flag); this.tasks.setControlFlag(4, flag && flag1); this.tasks.setControlFlag(2, flag); } } } }
/** * Returns if this entity is in water and will end up adding the waters velocity to the entity */ public boolean handleWaterMovement() { if (this.getRidingEntity() instanceof EntityBoat) { this.inWater = false; } else if (this.world.handleMaterialAcceleration(this.getEntityBoundingBox().expand(0.0D, -0.4000000059604645D, 0.0D).contract(0.001D), Material.WATER, this)) { if (!this.inWater && !this.firstUpdate) { this.resetHeight(); } this.fallDistance = 0.0F; this.inWater = true; this.extinguish(); } else { this.inWater = false; } return this.inWater; }
/** * Checks if the current block the entity is within of the specified material type */ public boolean isInsideOfMaterial(Material materialIn) { if (this.getRidingEntity() instanceof EntityBoat) { return false; } else { double d0 = this.posY + (double)this.getEyeHeight(); BlockPos blockpos = new BlockPos(this.posX, d0, this.posZ); IBlockState iblockstate = this.world.getBlockState(blockpos); if (iblockstate.getMaterial() == materialIn) { float f = BlockLiquid.getLiquidHeightPercent(iblockstate.getBlock().getMetaFromState(iblockstate)) - 0.11111111F; float f1 = (float)(blockpos.getY() + 1) - f; boolean flag = d0 < (double)f1; return !flag && this instanceof EntityPlayer ? false : flag; } else { return false; } } }
/** * Renders the desired {@code T} type Entity. */ public void doRender(EntityBoat entity, double x, double y, double z, float entityYaw, float partialTicks) { GlStateManager.pushMatrix(); this.setupTranslation(x, y, z); this.setupRotation(entity, entityYaw, partialTicks); this.bindEntityTexture(entity); if (this.renderOutlines) { GlStateManager.enableColorMaterial(); GlStateManager.enableOutlineMode(this.getTeamColor(entity)); } this.modelBoat.render(entity, partialTicks, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); if (this.renderOutlines) { GlStateManager.disableOutlineMode(); GlStateManager.disableColorMaterial(); } GlStateManager.popMatrix(); super.doRender(entity, x, y, z, entityYaw, partialTicks); }
public void setupRotation(EntityBoat p_188311_1_, float p_188311_2_, float p_188311_3_) { GlStateManager.rotate(180.0F - p_188311_2_, 0.0F, 1.0F, 0.0F); float f = (float)p_188311_1_.getTimeSinceHit() - p_188311_3_; float f1 = p_188311_1_.getDamageTaken() - p_188311_3_; if (f1 < 0.0F) { f1 = 0.0F; } if (f > 0.0F) { GlStateManager.rotate(MathHelper.sin(f) * f * f1 / 10.0F * (float)p_188311_1_.getForwardDirection(), 1.0F, 0.0F, 0.0F); } GlStateManager.scale(-1.0F, -1.0F, 1.0F); }
/** * Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); if (!this.worldObj.isRemote) { this.updateLeashedState(); if (this.ticksExisted % 5 == 0) { boolean flag = !(this.getControllingPassenger() instanceof EntityLiving); boolean flag1 = !(this.getRidingEntity() instanceof EntityBoat); this.tasks.setControlFlag(1, flag); this.tasks.setControlFlag(4, flag && flag1); this.tasks.setControlFlag(2, flag); } } }
/** * Returns if this entity is in water and will end up adding the waters velocity to the entity */ public boolean handleWaterMovement() { if (this.getRidingEntity() instanceof EntityBoat) { this.inWater = false; } else if (this.worldObj.handleMaterialAcceleration(this.getEntityBoundingBox().expand(0.0D, -0.4000000059604645D, 0.0D).contract(0.001D), Material.WATER, this)) { if (!this.inWater && !this.firstUpdate) { this.resetHeight(); } this.fallDistance = 0.0F; this.inWater = true; this.fire = 0; } else { this.inWater = false; } return this.inWater; }
/** * Checks if the current block the entity is within of the specified material type */ public boolean isInsideOfMaterial(Material materialIn) { if (this.getRidingEntity() instanceof EntityBoat) { return false; } else { double d0 = this.posY + (double)this.getEyeHeight(); BlockPos blockpos = new BlockPos(this.posX, d0, this.posZ); IBlockState iblockstate = this.worldObj.getBlockState(blockpos); Boolean result = iblockstate.getBlock().isEntityInsideMaterial(this.worldObj, blockpos, iblockstate, this, d0, materialIn, true); if (result != null) return result; if (iblockstate.getMaterial() == materialIn) { return net.minecraftforge.common.ForgeHooks.isInsideOfMaterial(materialIn, this, blockpos); } else { return false; } } }
private EntityBoat.Status getBoatStatus() { EntityBoat.Status status = this.getUnderwaterStatus(); if (status != null) { this.waterLevel = this.getEntityBoundingBox().maxY; return status; } else if (this.checkInWater()) { return EntityBoat.Status.IN_WATER; } else { float f = this.getFollower() == null ? 0 : this.getFollower().getBoatGlide(); if (f > 0.0F) { this.boatGlide = f; return EntityBoat.Status.ON_LAND; } else { return EntityBoat.Status.IN_AIR; } } }
private void performBoatLinkAction(EntityPlayer player, EntityBoat boat, ItemStack stack, IBoatLinker boatLinker) { EnumBoatLinkResult startResult = boatLinker.startBoatLink(player, boat); if(!startResult.isOk()) { EnumBoatLinkResult finishResult = boatLinker.finishBoatLink(player, boat); if(!finishResult.isOk()) { if(startResult.isOk()) { player.sendStatusMessage(new TextComponentTranslation("boatifull.message." + startResult.toString().toLowerCase()), false); } else { player.sendStatusMessage(new TextComponentTranslation("boatifull.message." + finishResult.toString().toLowerCase()), false); } } else { player.sendStatusMessage(new TextComponentTranslation("boatifull.message." + finishResult.toString().toLowerCase()), false); this.reduceStackSize(player, stack); } } else { player.sendStatusMessage(new TextComponentTranslation("boatifull.message." + startResult.toString().toLowerCase()), false); } }
@Override public void onEntityLeaveWorld(Entity entity) { if(!entity.getEntityWorld().isRemote) { if(entity instanceof EntityBoat) { EntityBoat boat = (EntityBoat) entity; if(linkingBoatToPlayer.containsKey(boat)) { removeLinkingProgress(boat); } if(this.boatLinks.containsKey(boat)) { this.unlinkBoat(boat); } getBoatsLinkedToBoat(boat).forEach(this::unlinkBoat); } else if(entity instanceof EntityPlayer) { this.removeLinkingProgress((EntityPlayer) entity); } } }
@Override public void onTick(ItemStack stack, EntityPlayer entityIn) { if (!this.canTick(stack)) { return; } if (entityIn.getRidingEntity() instanceof EntityBoat) { EntityBoat boat = (EntityBoat) entityIn.getRidingEntity(); if (entityIn.moveForward > 0) { float reduce = 0.08F; //pulled from private EntityBoat.controlBoat() fn boat.motionX += net.minecraft.util.math.MathHelper.sin(-boat.rotationYaw * 0.017453292F) * reduce; boat.motionZ += net.minecraft.util.math.MathHelper.cos(boat.rotationYaw * 0.017453292F) * reduce; if (entityIn.getEntityWorld().rand.nextDouble() < 0.1) { super.damageCharm(entityIn, stack); } } } }
public void doRender(EntityBoat p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { GL11.glPushMatrix(); GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_, (float)p_76986_6_); GL11.glRotatef(180.0F - p_76986_8_, 0.0F, 1.0F, 0.0F); float f2 = (float)p_76986_1_.getTimeSinceHit() - p_76986_9_; float f3 = p_76986_1_.getDamageTaken() - p_76986_9_; if (f3 < 0.0F) { f3 = 0.0F; } if (f2 > 0.0F) { GL11.glRotatef(MathHelper.sin(f2) * f2 * f3 / 10.0F * (float)p_76986_1_.getForwardDirection(), 1.0F, 0.0F, 0.0F); } float f4 = 0.75F; GL11.glScalef(f4, f4, f4); GL11.glScalef(1.0F / f4, 1.0F / f4, 1.0F / f4); this.bindEntityTexture(p_76986_1_); GL11.glScalef(-1.0F, -1.0F, 1.0F); this.modelBoat.render(p_76986_1_, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); }
private void func_71015_k(double p_71015_1_, double p_71015_3_, double p_71015_5_) { if(this.field_70154_o != null) { int var7 = Math.round(MathHelper.func_76133_a(p_71015_1_ * p_71015_1_ + p_71015_3_ * p_71015_3_ + p_71015_5_ * p_71015_5_) * 100.0F); if(var7 > 0) { if(this.field_70154_o instanceof EntityMinecart) { this.func_71064_a(StatList.field_75956_r, var7); if(this.field_71073_d == null) { this.field_71073_d = new ChunkCoordinates(MathHelper.func_76128_c(this.field_70165_t), MathHelper.func_76128_c(this.field_70163_u), MathHelper.func_76128_c(this.field_70161_v)); } else if((double)this.field_71073_d.func_71569_e(MathHelper.func_76128_c(this.field_70165_t), MathHelper.func_76128_c(this.field_70163_u), MathHelper.func_76128_c(this.field_70161_v)) >= 1000000.0D) { this.func_71064_a(AchievementList.field_76025_q, 1); } } else if(this.field_70154_o instanceof EntityBoat) { this.func_71064_a(StatList.field_75955_s, var7); } else if(this.field_70154_o instanceof EntityPig) { this.func_71064_a(StatList.field_75954_t, var7); } } } }
public void func_76997_a(EntityBoat p_76997_1_, double p_76997_2_, double p_76997_4_, double p_76997_6_, float p_76997_8_, float p_76997_9_) { GL11.glPushMatrix(); GL11.glTranslatef((float)p_76997_2_, (float)p_76997_4_, (float)p_76997_6_); GL11.glRotatef(180.0F - p_76997_8_, 0.0F, 1.0F, 0.0F); float var10 = (float)p_76997_1_.func_70268_h() - p_76997_9_; float var11 = p_76997_1_.func_70271_g() - p_76997_9_; if(var11 < 0.0F) { var11 = 0.0F; } if(var10 > 0.0F) { GL11.glRotatef(MathHelper.func_76126_a(var10) * var10 * var11 / 10.0F * (float)p_76997_1_.func_70267_i(), 1.0F, 0.0F, 0.0F); } float var12 = 0.75F; GL11.glScalef(var12, var12, var12); GL11.glScalef(1.0F / var12, 1.0F / var12, 1.0F / var12); this.func_110777_b(p_76997_1_); GL11.glScalef(-1.0F, -1.0F, 1.0F); this.field_76998_a.func_78088_a(p_76997_1_, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); }
public ItemStack func_82487_b(IBlockSource p_82487_1_, ItemStack p_82487_2_) { EnumFacing var3 = BlockDispenser.func_100009_j_(p_82487_1_.func_82620_h()); World var4 = p_82487_1_.func_82618_k(); double var5 = p_82487_1_.func_82615_a() + (double)((float)var3.func_82601_c() * 1.125F); double var7 = p_82487_1_.func_82617_b() + (double)((float)var3.func_96559_d() * 1.125F); double var9 = p_82487_1_.func_82616_c() + (double)((float)var3.func_82599_e() * 1.125F); int var11 = p_82487_1_.func_82623_d() + var3.func_82601_c(); int var12 = p_82487_1_.func_82622_e() + var3.func_96559_d(); int var13 = p_82487_1_.func_82621_f() + var3.func_82599_e(); Material var14 = var4.func_72803_f(var11, var12, var13); double var15; if(Material.field_76244_g.equals(var14)) { var15 = 1.0D; } else { if(!Material.field_76249_a.equals(var14) || !Material.field_76244_g.equals(var4.func_72803_f(var11, var12 - 1, var13))) { return this.field_96464_b.func_82482_a(p_82487_1_, p_82487_2_); } var15 = 0.0D; } EntityBoat var17 = new EntityBoat(var4, var5, var7 + var15, var9); var4.func_72838_d(var17); p_82487_2_.func_77979_a(1); return p_82487_2_; }
@SubscribeEvent public void onLocalPlayerUpdate(LocalPlayerUpdateEvent event) { if (!getModManager().getMod("Freecam").isEnabled()) { if (isInWater(getLocalPlayer()) && !getLocalPlayer().isSneaking()) { getLocalPlayer().motionY = 0.1; if (getLocalPlayer().getRidingEntity() != null && !(getLocalPlayer().getRidingEntity() instanceof EntityBoat)) { getLocalPlayer().getRidingEntity().motionY = 0.3; } } } }
/** * Adds a value to a mounted movement statistic field - by minecart, boat, or pig. */ private void addMountedMovementStat(double p_71015_1_, double p_71015_3_, double p_71015_5_) { if (this.ridingEntity != null) { int i = Math.round(MathHelper.sqrt_double(p_71015_1_ * p_71015_1_ + p_71015_3_ * p_71015_3_ + p_71015_5_ * p_71015_5_) * 100.0F); if (i > 0) { if (this.ridingEntity instanceof EntityMinecart) { this.addStat(StatList.distanceByMinecartStat, i); if (this.startMinecartRidingCoordinate == null) { this.startMinecartRidingCoordinate = new BlockPos(this); } else if (this.startMinecartRidingCoordinate.distanceSq((double)MathHelper.floor_double(this.posX), (double)MathHelper.floor_double(this.posY), (double)MathHelper.floor_double(this.posZ)) >= 1000000.0D) { this.triggerAchievement(AchievementList.onARail); } } else if (this.ridingEntity instanceof EntityBoat) { this.addStat(StatList.distanceByBoatStat, i); } else if (this.ridingEntity instanceof EntityPig) { this.addStat(StatList.distanceByPigStat, i); } else if (this.ridingEntity instanceof EntityHorse) { this.addStat(StatList.distanceByHorseStat, i); } } } }
/** * Add all collision boxes of this Block to the list that intersect with the given mask. */ public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity) { if (collidingEntity == null || !(collidingEntity instanceof EntityBoat)) { super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity); } }
/** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render<T extends Entity>) and this method has signature public void doRender(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doe */ public void doRender(EntityBoat entity, double x, double y, double z, float entityYaw, float partialTicks) { GlStateManager.pushMatrix(); GlStateManager.translate((float)x, (float)y + 0.25F, (float)z); GlStateManager.rotate(180.0F - entityYaw, 0.0F, 1.0F, 0.0F); float f = (float)entity.getTimeSinceHit() - partialTicks; float f1 = entity.getDamageTaken() - partialTicks; if (f1 < 0.0F) { f1 = 0.0F; } if (f > 0.0F) { GlStateManager.rotate(MathHelper.sin(f) * f * f1 / 10.0F * (float)entity.getForwardDirection(), 1.0F, 0.0F, 0.0F); } float f2 = 0.75F; GlStateManager.scale(f2, f2, f2); GlStateManager.scale(1.0F / f2, 1.0F / f2, 1.0F / f2); this.bindEntityTexture(entity); GlStateManager.scale(-1.0F, -1.0F, 1.0F); this.modelBoat.render(entity, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GlStateManager.popMatrix(); super.doRender(entity, x, y, z, entityYaw, partialTicks); }