From 8fe432230da486f510a7c79af95440a8492fbc3e Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 1 Mar 2016 23:04:07 -0800 Subject: [PATCH] Fix broken patches for EntityMinecart --- .../entity/item/EntityMinecart.java.patch | 272 +++++++++++++++++- 1 file changed, 271 insertions(+), 1 deletion(-) diff --git a/patches.mcp/minecraft/net/minecraft/entity/item/EntityMinecart.java.patch b/patches.mcp/minecraft/net/minecraft/entity/item/EntityMinecart.java.patch index 4a0a53dd3..1e93f3997 100644 --- a/patches.mcp/minecraft/net/minecraft/entity/item/EntityMinecart.java.patch +++ b/patches.mcp/minecraft/net/minecraft/entity/item/EntityMinecart.java.patch @@ -152,7 +152,15 @@ { double d17 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); -@@ -574,8 +605,14 @@ +@@ -526,6 +557,7 @@ + this.setPosition(this.posX, this.posY, this.posZ); + double d22 = this.motionX; + double d23 = this.motionZ; ++ this.moveMinecartOnRail(p_180460_1_); + + if (this.func_184207_aI()) + { +@@ -574,8 +606,14 @@ this.motionZ = d5 * (double)(i - p_180460_1_.getZ()); } @@ -168,3 +176,265 @@ double d15 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); if (d15 > 0.01D) +@@ -795,13 +833,19 @@ + + public void applyEntityCollision(Entity entityIn) + { ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartCollisionEvent(this, entityIn)); ++ if (getCollisionHandler() != null) ++ { ++ getCollisionHandler().onEntityCollision(this, entityIn); ++ return; ++ } + if (!this.worldObj.isRemote) + { + if (!entityIn.noClip && !this.noClip) + { + if (!this.func_184196_w(entityIn)) + { +- if (entityIn instanceof EntityLivingBase && this.func_184264_v() == EntityMinecart.Type.RIDEABLE && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.01D && !(entityIn instanceof EntityPlayer) && !(entityIn instanceof EntityIronGolem) && !this.func_184207_aI() && !entityIn.func_184218_aH()) ++ if (entityIn instanceof EntityLivingBase && canBeRidden() && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.01D && !(entityIn instanceof EntityPlayer) && !(entityIn instanceof EntityIronGolem) && !this.func_184207_aI() && !entityIn.func_184218_aH()) + { + entityIn.func_184220_m(this); + } +@@ -847,7 +891,7 @@ + double d7 = entityIn.motionX + this.motionX; + double d8 = entityIn.motionZ + this.motionZ; + +- if (((EntityMinecart)entityIn).func_184264_v() == EntityMinecart.Type.FURNACE && this.func_184264_v() != EntityMinecart.Type.FURNACE) ++ if (((EntityMinecart)entityIn).isPoweredCart() && !isPoweredCart()) + { + this.motionX *= 0.20000000298023224D; + this.motionZ *= 0.20000000298023224D; +@@ -855,7 +899,7 @@ + entityIn.motionX *= 0.949999988079071D; + entityIn.motionZ *= 0.949999988079071D; + } +- else if (((EntityMinecart)entityIn).func_184264_v() != EntityMinecart.Type.FURNACE && this.func_184264_v() == EntityMinecart.Type.FURNACE) ++ else if (!((EntityMinecart)entityIn).isPoweredCart() && isPoweredCart()) + { + entityIn.motionX *= 0.20000000298023224D; + entityIn.motionZ *= 0.20000000298023224D; +@@ -981,7 +1025,222 @@ + { + this.func_184212_Q().func_187227_b(field_184270_f, Boolean.valueOf(p_94096_1_)); + } ++ ++ /* =================================== FORGE START ===========================================*/ ++ private BlockPos getCurrentRailPosition() ++ { ++ int x = MathHelper.floor_double(this.posX); ++ int y = MathHelper.floor_double(this.posY); ++ int z = MathHelper.floor_double(this.posZ); + ++ if (BlockRailBase.isRailBlock(this.worldObj, new BlockPos(x, y - 1, z))) y--; ++ return new BlockPos(x, y, z); ++ } ++ ++ protected double getMaxSpeed() ++ { ++ if (!canUseRail()) return getMaximumSpeed(); ++ BlockPos pos = this.getCurrentRailPosition(); ++ IBlockState state = this.worldObj.getBlockState(pos); ++ if (!BlockRailBase.isRailBlock(state)) return getMaximumSpeed(); ++ ++ float railMaxSpeed = ((BlockRailBase)state.getBlock()).getRailMaxSpeed(worldObj, this, pos); ++ return Math.min(railMaxSpeed, getCurrentCartSpeedCapOnRail()); ++ } ++ ++ /** ++ * Moved to allow overrides. ++ * This code handles minecart movement and speed capping when on a rail. ++ */ ++ public void moveMinecartOnRail(BlockPos pos) ++ { ++ double mX = this.motionX; ++ double mZ = this.motionZ; ++ ++ if (this.riddenByEntity != null) ++ { ++ mX *= 0.75D; ++ mZ *= 0.75D; ++ } ++ ++ double max = this.getMaxSpeed(); ++ mX = MathHelper.clamp_double(mX, -max, max); ++ mZ = MathHelper.clamp_double(mZ, -max, max); ++ this.moveEntity(mX, 0.0D, mZ); ++ } ++ ++ /** ++ * Gets the current global Minecart Collision handler if none ++ * is registered, returns null ++ * @return The collision handler or null ++ */ ++ public static net.minecraftforge.common.IMinecartCollisionHandler getCollisionHandler() ++ { ++ return collisionHandler; ++ } ++ ++ /** ++ * Sets the global Minecart Collision handler, overwrites any ++ * that is currently set. ++ * @param handler The new handler ++ */ ++ public static void setCollisionHandler(net.minecraftforge.common.IMinecartCollisionHandler handler) ++ { ++ collisionHandler = handler; ++ } ++ ++ /** ++ * This function returns an ItemStack that represents this cart. ++ * This should be an ItemStack that can be used by the player to place the cart, ++ * but is not necessary the item the cart drops when destroyed. ++ * @return An ItemStack that can be used to place the cart. ++ */ ++ public ItemStack getCartItem() ++ { ++ if (this instanceof EntityMinecartFurnace) ++ { ++ return new ItemStack(Items.furnace_minecart); ++ } ++ else if (this instanceof EntityMinecartChest) ++ { ++ return new ItemStack(Items.chest_minecart); ++ } ++ else if (this instanceof EntityMinecartTNT) ++ { ++ return new ItemStack(Items.tnt_minecart); ++ } ++ else if (this instanceof EntityMinecartHopper) ++ { ++ return new ItemStack(Items.hopper_minecart); ++ } ++ else if (this instanceof EntityMinecartCommandBlock) ++ { ++ return new ItemStack(Items.command_block_minecart); ++ } ++ return new ItemStack(Items.minecart); ++ } ++ ++ /** ++ * Returns true if this cart can currently use rails. ++ * This function is mainly used to gracefully detach a minecart from a rail. ++ * @return True if the minecart can use rails. ++ */ ++ public boolean canUseRail() ++ { ++ return canUseRail; ++ } ++ ++ /** ++ * Set whether the minecart can use rails. ++ * This function is mainly used to gracefully detach a minecart from a rail. ++ * @param use Whether the minecart can currently use rails. ++ */ ++ public void setCanUseRail(boolean use) ++ { ++ canUseRail = use; ++ } ++ ++ /** ++ * Return false if this cart should not call onMinecartPass() and should ignore Powered Rails. ++ * @return True if this cart should call onMinecartPass(). ++ */ ++ public boolean shouldDoRailFunctions() ++ { ++ return true; ++ } ++ ++ /** ++ * Returns true if this cart is self propelled. ++ * @return True if powered. ++ */ ++ public boolean isPoweredCart() ++ { ++ return getMinecartType() == EntityMinecart.EnumMinecartType.FURNACE; ++ } ++ ++ /** ++ * Returns true if this cart can be ridden by an Entity. ++ * @return True if this cart can be ridden. ++ */ ++ public boolean canBeRidden() ++ { ++ return this.getMinecartType() == EntityMinecart.EnumMinecartType.RIDEABLE; ++ } ++ ++ /** ++ * Getters/setters for physics variables ++ */ ++ ++ /** ++ * Returns the carts max speed when traveling on rails. Carts going faster ++ * than 1.1 cause issues with chunk loading. Carts cant traverse slopes or ++ * corners at greater than 0.5 - 0.6. This value is compared with the rails ++ * max speed and the carts current speed cap to determine the carts current ++ * max speed. A normal rail's max speed is 0.4. ++ * ++ * @return Carts max speed. ++ */ ++ public float getMaxCartSpeedOnRail() ++ { ++ return 1.2f; ++ } ++ ++ /** ++ * Returns the current speed cap for the cart when traveling on rails. This ++ * functions differs from getMaxCartSpeedOnRail() in that it controls ++ * current movement and cannot be overridden. The value however can never be ++ * higher than getMaxCartSpeedOnRail(). ++ * ++ * @return ++ */ ++ public final float getCurrentCartSpeedCapOnRail() ++ { ++ return currentSpeedRail; ++ } ++ ++ public final void setCurrentCartSpeedCapOnRail(float value) ++ { ++ value = Math.min(value, getMaxCartSpeedOnRail()); ++ currentSpeedRail = value; ++ } ++ ++ public float getMaxSpeedAirLateral() ++ { ++ return maxSpeedAirLateral; ++ } ++ ++ public void setMaxSpeedAirLateral(float value) ++ { ++ maxSpeedAirLateral = value; ++ } ++ ++ public float getMaxSpeedAirVertical() ++ { ++ return maxSpeedAirVertical; ++ } ++ ++ public void setMaxSpeedAirVertical(float value) ++ { ++ maxSpeedAirVertical = value; ++ } ++ ++ public double getDragAir() ++ { ++ return dragAir; ++ } ++ ++ public void setDragAir(double value) ++ { ++ dragAir = value; ++ } ++ ++ public double getSlopeAdjustment() ++ { ++ return 0.0078125D; ++ } ++ ++ /* =================================== FORGE END ===========================================*/ ++ + public static enum Type + { + RIDEABLE(0, "MinecartRideable"),