From 316bf8d4489d1148076b50423087addca272d977 Mon Sep 17 00:00:00 2001 From: LexManos Date: Tue, 7 Aug 2012 16:54:14 -0700 Subject: [PATCH] Finished World and EntityMinecart patches. --- .../client/event/sound/SoundEvent.java | 20 + common/forge_at.cfg | 18 + .../common}/IMinecartCollisionHandler.java | 2 +- .../event/entity/EntityEvent.java | 10 +- .../minecart/MinecartCollisionEvent.java | 15 + .../event/entity/minecart/MinecartEvent.java | 16 + .../minecart/MinecartInteractEvent.java | 17 + .../entity/minecart/MinecartUpdateEvent.java | 18 + .../event/world/WorldEvent.java | 20 +- .../org.eclipse.e4.workbench/workbench.xmi | 43 +- .../minecraft/src/EntityMinecart.java.patch | 945 ++++++++++++++++++ .../net/minecraft/src/World.java.patch | 295 +++++- .../net/minecraft/src/WorldServer.java.patch | 19 + 13 files changed, 1396 insertions(+), 42 deletions(-) rename {forge_common/net/minecraft/src/forge => common/net/minecraftforge/common}/IMinecartCollisionHandler.java (98%) create mode 100644 common/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java create mode 100644 common/net/minecraftforge/event/entity/minecart/MinecartEvent.java create mode 100644 common/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java create mode 100644 common/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java create mode 100644 patches/minecraft/net/minecraft/src/EntityMinecart.java.patch create mode 100644 patches/minecraft/net/minecraft/src/WorldServer.java.patch diff --git a/client/net/minecraftforge/client/event/sound/SoundEvent.java b/client/net/minecraftforge/client/event/sound/SoundEvent.java index 3b8ec127d..af3e45064 100644 --- a/client/net/minecraftforge/client/event/sound/SoundEvent.java +++ b/client/net/minecraftforge/client/event/sound/SoundEvent.java @@ -1,8 +1,10 @@ package net.minecraftforge.client.event.sound; +import net.minecraft.src.Entity; import net.minecraft.src.SoundManager; import net.minecraft.src.SoundPoolEntry; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.Cancelable; import net.minecraftforge.event.Event; public class SoundEvent extends Event @@ -114,9 +116,27 @@ public class SoundEvent extends Event this.z = z; } } + public static class PlaySoundEffectEvent extends SoundResultEvent { public PlaySoundEffectEvent(SoundManager manager, SoundPoolEntry source, String name, float volume, float pitch) { super(manager, source, name, volume, pitch); } } + + @Cancelable + public static class PlaySoundAtEntityEvent extends SoundEvent + { + public final Entity entity; + public String name; + public final float volume; + public final float pitch; + + public PlaySoundAtEntityEvent(Entity entity, String name, float volume, float pitch) + { + this.entity = entity; + this.name = name; + this.volume = volume; + this.pitch = pitch; + } + } } \ No newline at end of file diff --git a/common/forge_at.cfg b/common/forge_at.cfg index ca370a477..1805bfbf2 100644 --- a/common/forge_at.cfg +++ b/common/forge_at.cfg @@ -36,3 +36,21 @@ public jv.aM # carryoverDamage # EntityPlayerMP public gt.bO()V # incrementWindowID() public gt.cq # currentWindowId +# EntityMinecart +protected nj.d # cargoItems +protected nj.e # fuel +protected nj.f # +protected nj.g # +protected nj.h # turnProgress +protected nj.i # minecartX +protected nj.j # minecartY +protected nj.an # minecartZ +protected nj.ao # minecartYaw +protected nj.ap # minecartPitch +protected nj.aq # velocityX +protected nj.ar # velocityY +protected nj.as # velocityZ +public nj.h()Z # isMinecartPowered +# World + + diff --git a/forge_common/net/minecraft/src/forge/IMinecartCollisionHandler.java b/common/net/minecraftforge/common/IMinecartCollisionHandler.java similarity index 98% rename from forge_common/net/minecraft/src/forge/IMinecartCollisionHandler.java rename to common/net/minecraftforge/common/IMinecartCollisionHandler.java index cf4f52181..e69c3b237 100644 --- a/forge_common/net/minecraft/src/forge/IMinecartCollisionHandler.java +++ b/common/net/minecraftforge/common/IMinecartCollisionHandler.java @@ -1,4 +1,4 @@ -package net.minecraft.src.forge; +package net.minecraftforge.common; import net.minecraft.src.AxisAlignedBB; import net.minecraft.src.Entity; diff --git a/common/net/minecraftforge/event/entity/EntityEvent.java b/common/net/minecraftforge/event/entity/EntityEvent.java index a794f8521..c34b5964b 100644 --- a/common/net/minecraftforge/event/entity/EntityEvent.java +++ b/common/net/minecraftforge/event/entity/EntityEvent.java @@ -5,15 +5,19 @@ import net.minecraftforge.event.Event; public class EntityEvent extends Event { - private final Entity entity; + public final Entity entity; public EntityEvent(Entity entity) { this.entity = entity; } - public Entity getEntity() + public static class CanUpdate extends EntityEvent { - return entity; + public boolean canUpdate = false; + public CanUpdate(Entity entity) + { + super(entity); + } } } diff --git a/common/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java b/common/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java new file mode 100644 index 000000000..724a42b01 --- /dev/null +++ b/common/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java @@ -0,0 +1,15 @@ +package net.minecraftforge.event.entity.minecart; + +import net.minecraft.src.Entity; +import net.minecraft.src.EntityMinecart; + +public class MinecartCollisionEvent extends MinecartEvent +{ + public final Entity collider; + + public MinecartCollisionEvent(EntityMinecart minecart, Entity collider) + { + super(minecart); + this.collider = collider; + } +} diff --git a/common/net/minecraftforge/event/entity/minecart/MinecartEvent.java b/common/net/minecraftforge/event/entity/minecart/MinecartEvent.java new file mode 100644 index 000000000..8c595b713 --- /dev/null +++ b/common/net/minecraftforge/event/entity/minecart/MinecartEvent.java @@ -0,0 +1,16 @@ +package net.minecraftforge.event.entity.minecart; + +import net.minecraft.src.Entity; +import net.minecraft.src.EntityMinecart; +import net.minecraftforge.event.entity.EntityEvent; + +public class MinecartEvent extends EntityEvent +{ + public final EntityMinecart minecart; + + public MinecartEvent(EntityMinecart minecart) + { + super(minecart); + this.minecart = minecart; + } +} diff --git a/common/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java b/common/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java new file mode 100644 index 000000000..ea22dc0b3 --- /dev/null +++ b/common/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java @@ -0,0 +1,17 @@ +package net.minecraftforge.event.entity.minecart; + +import net.minecraft.src.EntityMinecart; +import net.minecraft.src.EntityPlayer; +import net.minecraftforge.event.Cancelable; + +@Cancelable +public class MinecartInteractEvent extends MinecartEvent +{ + public final EntityPlayer player; + + public MinecartInteractEvent(EntityMinecart minecart, EntityPlayer player) + { + super(minecart); + this.player = player; + } +} diff --git a/common/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java b/common/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java new file mode 100644 index 000000000..ab990919a --- /dev/null +++ b/common/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java @@ -0,0 +1,18 @@ +package net.minecraftforge.event.entity.minecart; + +import net.minecraft.src.EntityMinecart; + +public class MinecartUpdateEvent extends MinecartEvent +{ + public final float x; + public final float y; + public final float z; + + public MinecartUpdateEvent(EntityMinecart minecart, float x, float y, float z) + { + super(minecart); + this.x = x; + this.y = y; + this.z = z; + } +} diff --git a/common/net/minecraftforge/event/world/WorldEvent.java b/common/net/minecraftforge/event/world/WorldEvent.java index cad828b6b..161be594d 100644 --- a/common/net/minecraftforge/event/world/WorldEvent.java +++ b/common/net/minecraftforge/event/world/WorldEvent.java @@ -5,15 +5,25 @@ import net.minecraftforge.event.Event; public class WorldEvent extends Event { - private final World world; - + public final World world; + public WorldEvent(World world) { this.world = world; } - - public World getWorld() + + public static class Load extends WorldEvent { - return world; + public Load(World world) { super(world); } + } + + public static class Unload extends WorldEvent + { + public Unload(World world) { super(world); } + } + + public static class Save extends WorldEvent + { + public Save(World world) { super(world); } } } diff --git a/eclipse/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/eclipse/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi index 715659af9..00517717f 100644 --- a/eclipse/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi +++ b/eclipse/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -1,7 +1,7 @@ activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration - + topLevel shellMaximized @@ -67,8 +67,8 @@ persp.newWizSC:org.eclipse.mylyn.tasks.ui.wizards.new.repository.task persp.viewSC:org.eclipse.wb.core.StructureView persp.viewSC:org.eclipse.wb.core.PaletteView - - + + newtablook org.eclipse.e4.primaryNavigationStack @@ -85,13 +85,13 @@ - - - - - + + + + + newtablook - + newtablook @@ -103,7 +103,7 @@ - + newtablook org.eclipse.e4.secondaryDataStack @@ -137,27 +137,12 @@ categoryTag:Help - + newtablook org.eclipse.e4.primaryDataStack EditorStack - - - Editor - removeOnHide - - - - Editor - removeOnHide - - - - Editor - removeOnHide - - - + + Editor removeOnHide @@ -185,7 +170,7 @@ View categoryTag:General - + View categoryTag:General diff --git a/patches/minecraft/net/minecraft/src/EntityMinecart.java.patch b/patches/minecraft/net/minecraft/src/EntityMinecart.java.patch new file mode 100644 index 000000000..b3e030d1b --- /dev/null +++ b/patches/minecraft/net/minecraft/src/EntityMinecart.java.patch @@ -0,0 +1,945 @@ +--- ../src_base/minecraft/net/minecraft/src/EntityMinecart.java ++++ ../src_work/minecraft/net/minecraft/src/EntityMinecart.java +@@ -1,6 +1,14 @@ + package net.minecraft.src; + ++import java.util.ArrayList; + import java.util.List; ++ ++import net.minecraftforge.common.IMinecartCollisionHandler; ++import net.minecraftforge.common.MinecartRegistry; ++import net.minecraftforge.common.MinecraftForge; ++import net.minecraftforge.event.entity.minecart.MinecartCollisionEvent; ++import net.minecraftforge.event.entity.minecart.MinecartInteractEvent; ++import net.minecraftforge.event.entity.minecart.MinecartUpdateEvent; + + public class EntityMinecart extends Entity implements IInventory + { +@@ -26,6 +34,23 @@ + private double velocityY; + private double velocityZ; + ++ /* Forge: Minecart Compatibility Layer Integration. */ ++ public static float defaultMaxSpeedRail = 0.4f; ++ public static float defaultMaxSpeedGround = 0.4f; ++ public static float defaultMaxSpeedAirLateral = 0.4f; ++ public static float defaultMaxSpeedAirVertical = -1f; ++ public static double defaultDragAir = 0.94999998807907104D; ++ protected boolean canUseRail = true; ++ protected boolean canBePushed = true; ++ private static IMinecartCollisionHandler collisionHandler = null; ++ ++ /* Instance versions of the above physics properties */ ++ protected float maxSpeedRail; ++ protected float maxSpeedGround; ++ protected float maxSpeedAirLateral; ++ protected float maxSpeedAirVertical; ++ protected double dragAir; ++ + public EntityMinecart(World par1World) + { + super(par1World); +@@ -35,6 +60,18 @@ + this.preventEntitySpawning = true; + this.setSize(0.98F, 0.7F); + this.yOffset = this.height / 2.0F; ++ ++ maxSpeedRail = defaultMaxSpeedRail; ++ maxSpeedGround = defaultMaxSpeedGround; ++ maxSpeedAirLateral = defaultMaxSpeedAirLateral; ++ maxSpeedAirVertical = defaultMaxSpeedAirVertical; ++ dragAir = defaultDragAir; ++ } ++ ++ public EntityMinecart(World world, int type) ++ { ++ this(world); ++ minecartType = type; + } + + /** +@@ -60,6 +97,10 @@ + */ + public AxisAlignedBB getCollisionBox(Entity par1Entity) + { ++ if (getCollisionHandler() != null) ++ { ++ return getCollisionHandler().getCollisionBox(this, par1Entity); ++ } + return par1Entity.boundingBox; + } + +@@ -68,6 +109,10 @@ + */ + public AxisAlignedBB getBoundingBox() + { ++ if (getCollisionHandler() != null) ++ { ++ return getCollisionHandler().getBoundingBox(this); ++ } + return null; + } + +@@ -76,7 +121,7 @@ + */ + public boolean canBePushed() + { +- return true; ++ return canBePushed; + } + + public EntityMinecart(World par1World, double par2, double par4, double par6, int par8) +@@ -125,48 +170,7 @@ + } + + this.setDead(); +- this.dropItemWithOffset(Item.minecartEmpty.shiftedIndex, 1, 0.0F); +- +- if (this.minecartType == 1) +- { +- EntityMinecart var3 = this; +- +- for (int var4 = 0; var4 < var3.getSizeInventory(); ++var4) +- { +- ItemStack var5 = var3.getStackInSlot(var4); +- +- if (var5 != null) +- { +- float var6 = this.rand.nextFloat() * 0.8F + 0.1F; +- float var7 = this.rand.nextFloat() * 0.8F + 0.1F; +- float var8 = this.rand.nextFloat() * 0.8F + 0.1F; +- +- while (var5.stackSize > 0) +- { +- int var9 = this.rand.nextInt(21) + 10; +- +- if (var9 > var5.stackSize) +- { +- var9 = var5.stackSize; +- } +- +- var5.stackSize -= var9; +- EntityItem var10 = new EntityItem(this.worldObj, this.posX + (double)var6, this.posY + (double)var7, this.posZ + (double)var8, new ItemStack(var5.itemID, var9, var5.getItemDamage())); +- float var11 = 0.05F; +- var10.motionX = (double)((float)this.rand.nextGaussian() * var11); +- var10.motionY = (double)((float)this.rand.nextGaussian() * var11 + 0.2F); +- var10.motionZ = (double)((float)this.rand.nextGaussian() * var11); +- this.worldObj.spawnEntityInWorld(var10); +- } +- } +- } +- +- this.dropItemWithOffset(Block.chest.blockID, 1, 0.0F); +- } +- else if (this.minecartType == 2) +- { +- this.dropItemWithOffset(Block.stoneOvenIdle.blockID, 1, 0.0F); +- } ++ dropCartAsItem(); + } + + return true; +@@ -259,7 +263,7 @@ + this.kill(); + } + +- if (this.isMinecartPowered() && this.rand.nextInt(4) == 0) ++ if (this.isMinecartPowered() && this.rand.nextInt(4) == 0 && minecartType == 2 && getClass() == EntityMinecart.class) + { + this.worldObj.spawnParticle("largesmoke", this.posX, this.posY + 0.8D, this.posZ, 0.0D, 0.0D, 0.0D); + } +@@ -303,49 +307,26 @@ + double var6 = 0.0078125D; + int var8 = this.worldObj.getBlockId(var1, var2, var3); + +- if (BlockRail.isRailBlock(var8)) ++ if (canUseRail() && BlockRail.isRailBlock(var8)) + { + Vec3 var9 = this.func_70489_a(this.posX, this.posY, this.posZ); +- int var10 = this.worldObj.getBlockMetadata(var1, var2, var3); ++ int var10 = ((BlockRail)Block.blocksList[var8]).getBasicRailMetadata(worldObj, this, var1, var2, var3); + this.posY = (double)var2; + boolean var11 = false; + boolean var12 = false; + + if (var8 == Block.railPowered.blockID) + { +- var11 = (var10 & 8) != 0; ++ var11 = (worldObj.getBlockMetadata(var1, var2, var3) & 8) != 0; + var12 = !var11; + } + +- if (((BlockRail)Block.blocksList[var8]).isPowered()) +- { +- var10 &= 7; +- } +- + if (var10 >= 2 && var10 <= 5) + { + this.posY = (double)(var2 + 1); + } + +- if (var10 == 2) +- { +- this.motionX -= var6; +- } +- +- if (var10 == 3) +- { +- this.motionX += var6; +- } +- +- if (var10 == 4) +- { +- this.motionZ += var6; +- } +- +- if (var10 == 5) +- { +- this.motionZ -= var6; +- } ++ adjustSlopeVelocities(var10); + + int[][] var13 = field_70500_g[var10]; + double var14 = (double)(var13[1][0] - var13[0][0]); +@@ -378,7 +359,7 @@ + } + } + +- if (var12) ++ if (var12 && shouldDoRailFunctions()) + { + var24 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); + +@@ -426,36 +407,8 @@ + this.posX = var26 + var14 * var24; + this.posZ = var28 + var16 * var24; + this.setPosition(this.posX, this.posY + (double)this.yOffset, this.posZ); +- var34 = this.motionX; +- var36 = this.motionZ; +- +- if (this.riddenByEntity != null) +- { +- var34 *= 0.75D; +- var36 *= 0.75D; +- } +- +- if (var34 < -var4) +- { +- var34 = -var4; +- } +- +- if (var34 > var4) +- { +- var34 = var4; +- } +- +- if (var36 < -var4) +- { +- var36 = -var4; +- } +- +- if (var36 > var4) +- { +- var36 = var4; +- } +- +- this.moveEntity(var34, 0.0D, var36); ++ ++ moveMinecartOnRail(var1, var2, var3); + + if (var13[0][1] != 0 && MathHelper.floor_double(this.posX) - var1 == var13[0][0] && MathHelper.floor_double(this.posZ) - var3 == var13[0][2]) + { +@@ -466,42 +419,7 @@ + this.setPosition(this.posX, this.posY + (double)var13[1][1], this.posZ); + } + +- if (this.riddenByEntity != null) +- { +- this.motionX *= 0.996999979019165D; +- this.motionY *= 0.0D; +- this.motionZ *= 0.996999979019165D; +- } +- else +- { +- if (this.minecartType == 2) +- { +- double var38 = this.pushX * this.pushX + this.pushZ * this.pushZ; +- +- if (var38 > 1.0E-4D) +- { +- var38 = (double)MathHelper.sqrt_double(var38); +- this.pushX /= var38; +- this.pushZ /= var38; +- double var40 = 0.04D; +- this.motionX *= 0.800000011920929D; +- this.motionY *= 0.0D; +- this.motionZ *= 0.800000011920929D; +- this.motionX += this.pushX * var40; +- this.motionZ += this.pushZ * var40; +- } +- else +- { +- this.motionX *= 0.8999999761581421D; +- this.motionY *= 0.0D; +- this.motionZ *= 0.8999999761581421D; +- } +- } +- +- this.motionX *= 0.9599999785423279D; +- this.motionY *= 0.0D; +- this.motionZ *= 0.9599999785423279D; +- } ++ applyDragAndPushForces(); + + Vec3 var52 = this.func_70489_a(this.posX, this.posY, this.posZ); + +@@ -531,30 +449,14 @@ + + double var41; + +- if (this.minecartType == 2) +- { +- var41 = this.pushX * this.pushX + this.pushZ * this.pushZ; +- +- if (var41 > 1.0E-4D && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.001D) +- { +- var41 = (double)MathHelper.sqrt_double(var41); +- this.pushX /= var41; +- this.pushZ /= var41; +- +- if (this.pushX * this.motionX + this.pushZ * this.motionZ < 0.0D) +- { +- this.pushX = 0.0D; +- this.pushZ = 0.0D; +- } +- else +- { +- this.pushX = this.motionX; +- this.pushZ = this.motionZ; +- } +- } +- } +- +- if (var11) ++ updatePushForces(); ++ ++ if(shouldDoRailFunctions()) ++ { ++ ((BlockRail)Block.blocksList[var8]).onMinecartPass(worldObj, this, var1, var2, var3); ++ } ++ ++ if (var11 && shouldDoRailFunctions()) + { + var41 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); + +@@ -592,41 +494,7 @@ + } + else + { +- if (this.motionX < -var4) +- { +- this.motionX = -var4; +- } +- +- if (this.motionX > var4) +- { +- this.motionX = var4; +- } +- +- if (this.motionZ < -var4) +- { +- this.motionZ = -var4; +- } +- +- if (this.motionZ > var4) +- { +- this.motionZ = var4; +- } +- +- if (this.onGround) +- { +- this.motionX *= 0.5D; +- this.motionY *= 0.5D; +- this.motionZ *= 0.5D; +- } +- +- this.moveEntity(this.motionX, this.motionY, this.motionZ); +- +- if (!this.onGround) +- { +- this.motionX *= 0.949999988079071D; +- this.motionY *= 0.949999988079071D; +- this.motionZ *= 0.949999988079071D; +- } ++ moveMinecartOffRail(var1, var2, var3); + } + + this.rotationPitch = 0.0F; +@@ -652,7 +520,18 @@ + } + + this.setRotation(this.rotationYaw, this.rotationPitch); +- List var15 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D)); ++ ++ AxisAlignedBB box = null; ++ if (getCollisionHandler() != null) ++ { ++ box = getCollisionHandler().getMinecartCollisionBox(this); ++ } ++ else ++ { ++ box = boundingBox.expand(0.2D, 0.0D, 0.2D); ++ } ++ ++ List var15 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, box); + + if (var15 != null && !var15.isEmpty()) + { +@@ -677,17 +556,8 @@ + this.riddenByEntity = null; + } + +- if (this.fuel > 0) +- { +- --this.fuel; +- } +- +- if (this.fuel <= 0) +- { +- this.pushX = this.pushZ = 0.0D; +- } +- +- this.setMinecartPowered(this.fuel > 0); ++ updateFuel(); ++ MinecraftForge.EVENT_BUS.post(new MinecartUpdateEvent(this, var1, var2, var3)); + } + } + +@@ -710,12 +580,7 @@ + } + else + { +- int var13 = this.worldObj.getBlockMetadata(var9, var10, var11); +- +- if (((BlockRail)Block.blocksList[var12]).isPowered()) +- { +- var13 &= 7; +- } ++ int var13 = ((BlockRail)Block.blocksList[var12]).getBasicRailMetadata(worldObj, this, var9, var10, var11); + + par3 = (double)var10; + +@@ -761,13 +626,8 @@ + + if (BlockRail.isRailBlock(var10)) + { +- int var11 = this.worldObj.getBlockMetadata(var7, var8, var9); ++ int var11 = ((BlockRail)Block.blocksList[var10]).getBasicRailMetadata(worldObj, this, var7, var8, var9); + par3 = (double)var8; +- +- if (((BlockRail)Block.blocksList[var10]).isPowered()) +- { +- var11 &= 7; +- } + + if (var11 >= 2 && var11 <= 5) + { +@@ -832,13 +692,14 @@ + { + par1NBTTagCompound.setInteger("Type", this.minecartType); + +- if (this.minecartType == 2) ++ if (isPoweredCart()) + { + par1NBTTagCompound.setDouble("PushX", this.pushX); + par1NBTTagCompound.setDouble("PushZ", this.pushZ); +- par1NBTTagCompound.setShort("Fuel", (short)this.fuel); +- } +- else if (this.minecartType == 1) ++ par1NBTTagCompound.setInteger("Fuel", this.fuel); ++ } ++ ++ if (getSizeInventory() > 0) + { + NBTTagList var2 = new NBTTagList(); + +@@ -864,13 +725,21 @@ + { + this.minecartType = par1NBTTagCompound.getInteger("Type"); + +- if (this.minecartType == 2) ++ if (isPoweredCart()) + { + this.pushX = par1NBTTagCompound.getDouble("PushX"); + this.pushZ = par1NBTTagCompound.getDouble("PushZ"); +- this.fuel = par1NBTTagCompound.getShort("Fuel"); +- } +- else if (this.minecartType == 1) ++ try ++ { ++ this.fuel = par1NBTTagCompound.getInteger("Fuel"); ++ } ++ catch (ClassCastException e) ++ { ++ this.fuel = par1NBTTagCompound.getShort("Fuel"); ++ } ++ } ++ ++ if (getSizeInventory() > 0) + { + NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); + this.cargoItems = new ItemStack[this.getSizeInventory()]; +@@ -898,11 +767,17 @@ + */ + public void applyEntityCollision(Entity par1Entity) + { ++ MinecraftForge.EVENT_BUS.post(new MinecartCollisionEvent(this, par1Entity)); ++ if (getCollisionHandler() != null) ++ { ++ getCollisionHandler().onEntityCollision(this, par1Entity); ++ return; ++ } + if (!this.worldObj.isRemote) + { + if (par1Entity != this.riddenByEntity) + { +- if (par1Entity instanceof EntityLiving && !(par1Entity instanceof EntityPlayer) && !(par1Entity instanceof EntityIronGolem) && this.minecartType == 0 && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.01D && this.riddenByEntity == null && par1Entity.ridingEntity == null) ++ if (par1Entity instanceof EntityLiving && !(par1Entity instanceof EntityPlayer) && !(par1Entity instanceof EntityIronGolem) && canBeRidden() && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.01D && this.riddenByEntity == null && par1Entity.ridingEntity == null) + { + par1Entity.mountEntity(this); + } +@@ -948,7 +823,7 @@ + double var18 = par1Entity.motionX + this.motionX; + double var20 = par1Entity.motionZ + this.motionZ; + +- if (((EntityMinecart)par1Entity).minecartType == 2 && this.minecartType != 2) ++ if (((EntityMinecart)par1Entity).isPoweredCart() && !isPoweredCart()) + { + this.motionX *= 0.20000000298023224D; + this.motionZ *= 0.20000000298023224D; +@@ -956,7 +831,7 @@ + par1Entity.motionX *= 0.949999988079071D; + par1Entity.motionZ *= 0.949999988079071D; + } +- else if (((EntityMinecart)par1Entity).minecartType != 2 && this.minecartType == 2) ++ else if (!((EntityMinecart)par1Entity).isPoweredCart() && isPoweredCart()) + { + par1Entity.motionX *= 0.20000000298023224D; + par1Entity.motionZ *= 0.20000000298023224D; +@@ -991,7 +866,7 @@ + */ + public int getSizeInventory() + { +- return 27; ++ return (minecartType == 1 && getClass() == EntityMinecart.class ? 27 : 0); + } + + /** +@@ -1094,7 +969,12 @@ + */ + public boolean interact(EntityPlayer par1EntityPlayer) + { +- if (this.minecartType == 0) ++ if (MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, par1EntityPlayer))) ++ { ++ return true; ++ } ++ ++ if (canBeRidden()) + { + if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer) + { +@@ -1106,14 +986,14 @@ + par1EntityPlayer.mountEntity(this); + } + } +- else if (this.minecartType == 1) ++ else if (getSizeInventory() > 0) + { + if (!this.worldObj.isRemote) + { + par1EntityPlayer.displayGUIChest(this); + } + } +- else if (this.minecartType == 2) ++ else if (this.minecartType == 2 && getClass() == EntityMinecart.class) + { + ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem(); + +@@ -1233,4 +1113,375 @@ + { + return this.dataWatcher.getWatchableObjectInt(18); + } ++ ++ /** ++ * Drops the cart as a item. The exact item dropped is defined by getItemDropped(). ++ */ ++ public void dropCartAsItem() ++ { ++ for(ItemStack item : getItemsDropped()) ++ { ++ entityDropItem(item, 0); ++ } ++ } ++ ++ /** ++ * Override this to define which items your cart drops when broken. ++ * This does not include items contained in the inventory, ++ * that is handled elsewhere. ++ * @return A list of items dropped. ++ */ ++ public List getItemsDropped() ++ { ++ List items = new ArrayList(); ++ items.add(new ItemStack(Item.minecartEmpty)); ++ ++ switch(minecartType) ++ { ++ case 1: ++ items.add(new ItemStack(Block.chest)); ++ break; ++ case 2: ++ items.add(new ItemStack(Block.stoneOvenIdle)); ++ break; ++ } ++ return items; ++ } ++ ++ /** ++ * 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. ++ * This is the item that was registered with the cart via the registerMinecart function, ++ * 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() ++ { ++ return MinecartRegistry.getItemForCart(this); ++ } ++ ++ /** ++ * Returns true if this cart is self propelled. ++ * @return True if powered. ++ */ ++ public boolean isPoweredCart() ++ { ++ return minecartType == 2 && getClass() == EntityMinecart.class; ++ } ++ ++ /** ++ * Returns true if this cart is a storage cart ++ * Some carts may have inventories but not be storage carts ++ * and some carts without inventories may be storage carts. ++ * @return True if this cart should be classified as a storage cart. ++ */ ++ public boolean isStorageCart() ++ { ++ return minecartType == 1 && getClass() == EntityMinecart.class; ++ } ++ ++ /** ++ * Returns true if this cart can be ridden by an Entity. ++ * @return True if this cart can be ridden. ++ */ ++ public boolean canBeRidden() ++ { ++ if(minecartType == 0 && getClass() == EntityMinecart.class) ++ { ++ return true; ++ } ++ return false; ++ } ++ ++ /** ++ * 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 IRail.onMinecartPass() and should ignore Powered Rails. ++ * @return True if this cart should call IRail.onMinecartPass(). ++ */ ++ public boolean shouldDoRailFunctions() ++ { ++ return true; ++ } ++ ++ /** ++ * Simply returns the minecartType variable. ++ * @return minecartType ++ */ ++ public int getMinecartType() ++ { ++ return minecartType; ++ } ++ ++ /** ++ * Gets the current global Minecart Collision handler if none ++ * is registered, returns null ++ * @return The collision handler or null ++ */ ++ public static 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(IMinecartCollisionHandler handler) ++ { ++ collisionHandler = handler; ++ } ++ ++ /** ++ * Carts should return their drag factor here ++ * @return The drag rate. ++ */ ++ protected double getDrag() ++ { ++ return riddenByEntity != null ? 0.99D : 0.96D; ++ } ++ ++ /** ++ * Moved to allow overrides. ++ * This code applies drag and updates push forces. ++ */ ++ protected void applyDragAndPushForces() ++ { ++ if(isPoweredCart()) ++ { ++ double d27 = MathHelper.sqrt_double(pushX * pushX + pushZ * pushZ); ++ if(d27 > 0.01D) ++ { ++ pushX /= d27; ++ pushZ /= d27; ++ double d29 = 0.04; ++ motionX *= 0.8D; ++ motionY *= 0.0D; ++ motionZ *= 0.8D; ++ motionX += pushX * d29; ++ motionZ += pushZ * d29; ++ } ++ else ++ { ++ motionX *= 0.9D; ++ motionY *= 0.0D; ++ motionZ *= 0.9D; ++ } ++ } ++ motionX *= getDrag(); ++ motionY *= 0.0D; ++ motionZ *= getDrag(); ++ } ++ ++ /** ++ * Moved to allow overrides. ++ * This code updates push forces. ++ */ ++ protected void updatePushForces() ++ { ++ if(isPoweredCart()) ++ { ++ double push = MathHelper.sqrt_double(pushX * pushX + pushZ * pushZ); ++ if(push > 0.01D && motionX * motionX + motionZ * motionZ > 0.001D) ++ { ++ pushX /= push; ++ pushZ /= push; ++ if(pushX * motionX + pushZ * motionZ < 0.0D) ++ { ++ pushX = 0.0D; ++ pushZ = 0.0D; ++ } ++ else ++ { ++ pushX = motionX; ++ pushZ = motionZ; ++ } ++ } ++ } ++ } ++ ++ /** ++ * Moved to allow overrides. ++ * This code handles minecart movement and speed capping when on a rail. ++ */ ++ protected void moveMinecartOnRail(int i, int j, int k) ++ { ++ int id = worldObj.getBlockId(i, j, k); ++ if (!BlockRail.isRailBlock(id)) ++ { ++ return; ++ } ++ float railMaxSpeed = ((BlockRail)Block.blocksList[id]).getRailMaxSpeed(worldObj, this, i, j, k); ++ ++ double maxSpeed = Math.min(railMaxSpeed, getMaxSpeedRail()); ++ double mX = motionX; ++ double mZ = motionZ; ++ if(riddenByEntity != null) ++ { ++ mX *= 0.75D; ++ mZ *= 0.75D; ++ } ++ if(mX < -maxSpeed) mX = -maxSpeed; ++ if(mX > maxSpeed) mX = maxSpeed; ++ if(mZ < -maxSpeed) mZ = -maxSpeed; ++ if(mZ > maxSpeed) mZ = maxSpeed; ++ moveEntity(mX, 0.0D, mZ); ++ } ++ ++ /** ++ * Moved to allow overrides. ++ * This code handles minecart movement and speed capping when not on a rail. ++ */ ++ protected void moveMinecartOffRail(int i, int j, int k) ++ { ++ double d2 = getMaxSpeedGround(); ++ if(!onGround) ++ { ++ d2 = getMaxSpeedAirLateral(); ++ } ++ if(motionX < -d2) motionX = -d2; ++ if(motionX > d2) motionX = d2; ++ if(motionZ < -d2) motionZ = -d2; ++ if(motionZ > d2) motionZ = d2; ++ double moveY = motionY; ++ if(getMaxSpeedAirVertical() > 0 && motionY > getMaxSpeedAirVertical()) ++ { ++ moveY = getMaxSpeedAirVertical(); ++ if(Math.abs(motionX) < 0.3f && Math.abs(motionZ) < 0.3f) ++ { ++ moveY = 0.15f; ++ motionY = moveY; ++ } ++ } ++ if(onGround) ++ { ++ motionX *= 0.5D; ++ motionY *= 0.5D; ++ motionZ *= 0.5D; ++ } ++ moveEntity(motionX, moveY, motionZ); ++ if(!onGround) ++ { ++ motionX *= getDragAir(); ++ motionY *= getDragAir(); ++ motionZ *= getDragAir(); ++ } ++ } ++ ++ /** ++ * Moved to allow overrides. ++ * This code applies fuel consumption. ++ */ ++ protected void updateFuel() ++ { ++ if (fuel > 0) fuel--; ++ if (fuel <= 0) pushX = pushZ = 0.0D; ++ setMinecartPowered(fuel > 0); ++ } ++ ++ /** ++ * Moved to allow overrides, This code handle slopes affecting velocity. ++ * @param metadata The blocks position metadata ++ */ ++ protected void adjustSlopeVelocities(int metadata) ++ { ++ double acceleration = 0.0078125D; ++ if (metadata == 2) ++ { ++ motionX -= acceleration; ++ } ++ else if (metadata == 3) ++ { ++ motionX += acceleration; ++ } ++ else if (metadata == 4) ++ { ++ motionZ += acceleration; ++ } ++ else if (metadata == 5) ++ { ++ motionZ -= acceleration; ++ } ++ } ++ ++ /** ++ * Getters/setters for physics variables ++ */ ++ ++ /** ++ * Returns the carts max speed. ++ * 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 to determine ++ * the carts current max speed. A normal rails max speed is 0.4. ++ * @return Carts max speed. ++ */ ++ public float getMaxSpeedRail() ++ { ++ return maxSpeedRail; ++ } ++ ++ public void setMaxSpeedRail(float value) ++ { ++ maxSpeedRail = value; ++ } ++ ++ public float getMaxSpeedGround() ++ { ++ return maxSpeedGround; ++ } ++ ++ public void setMaxSpeedGround(float value) ++ { ++ maxSpeedGround = 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; ++ } + } diff --git a/patches/minecraft/net/minecraft/src/World.java.patch b/patches/minecraft/net/minecraft/src/World.java.patch index ebf6ab1c6..d57fe8680 100644 --- a/patches/minecraft/net/minecraft/src/World.java.patch +++ b/patches/minecraft/net/minecraft/src/World.java.patch @@ -1,10 +1,14 @@ --- ../src_base/minecraft/net/minecraft/src/World.java +++ ../src_work/minecraft/net/minecraft/src/World.java -@@ -8,8 +8,17 @@ +@@ -8,8 +8,21 @@ import java.util.Random; import java.util.Set; ++import net.minecraftforge.client.event.sound.SoundEvent.PlaySoundAtEntityEvent; ++import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.Orientation; ++import net.minecraftforge.event.entity.EntityEvent; ++import net.minecraftforge.event.world.WorldEvent; + public abstract class World implements IBlockAccess { @@ -18,7 +22,33 @@ /** * boolean; if true updates scheduled by scheduleBlockUpdate happen immediately */ -@@ -273,7 +282,8 @@ +@@ -164,6 +177,7 @@ + this.chunkProvider = this.createChunkProvider(); + this.calculateInitialSkylight(); + this.calculateInitialWeather(); ++ MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(this)); + } + + public World(ISaveHandler par1ISaveHandler, String par2Str, WorldSettings par3WorldSettings, WorldProvider par4WorldProvider, Profiler par5Profiler) +@@ -210,6 +224,7 @@ + + this.calculateInitialSkylight(); + this.calculateInitialWeather(); ++ MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(this)); + } + + /** +@@ -264,7 +279,8 @@ + */ + public boolean isAirBlock(int par1, int par2, int par3) + { +- return this.getBlockId(par1, par2, par3) == 0; ++ int id = getBlockId(par1, par2, par3); ++ return id == 0 || Block.blocksList[id] == null || Block.blocksList[id].isAirBlock(this, par1, par2, par3); + } + + /** +@@ -273,7 +289,8 @@ public boolean blockHasTileEntity(int par1, int par2, int par3) { int var4 = this.getBlockId(par1, par2, par3); @@ -28,7 +58,205 @@ } /** -@@ -2562,8 +2572,7 @@ +@@ -999,7 +1016,7 @@ + int var12 = this.getBlockMetadata(var8, var9, var10); + Block var13 = Block.blocksList[var11]; + +- if ((!par4 || var13 == null || var13.getCollisionBoundingBoxFromPool(this, var8, var9, var10) != null) && var11 > 0 && var13.canCollideCheck(var12, par3)) ++ if (var13 != null && (!par4 || var13 == null || var13.getCollisionBoundingBoxFromPool(this, var8, var9, var10) != null) && var11 > 0 && var13.canCollideCheck(var12, par3)) + { + MovingObjectPosition var14 = var13.collisionRayTrace(this, var8, var9, var10, par1Vec3, par2Vec3); + +@@ -1199,6 +1216,12 @@ + */ + public void playSoundAtEntity(Entity par1Entity, String par2Str, float par3, float par4) + { ++ PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(par1Entity, par2Str, par3, par4); ++ if (MinecraftForge.EVENT_BUS.post(event)) ++ { ++ return; ++ } ++ par2Str = event.name; + if (par1Entity != null && par2Str != null) + { + Iterator var5 = this.worldAccesses.iterator(); +@@ -1862,7 +1885,7 @@ + + if (var8 != null) + { +- var8.removeChunkBlockTileEntity(var6.xCoord & 15, var6.yCoord, var6.zCoord & 15); ++ var8.cleanChunkBlockTileEntity(var6.xCoord & 15, var6.yCoord, var6.zCoord & 15); + } + } + } +@@ -1872,6 +1895,10 @@ + + if (!this.entityRemoval.isEmpty()) + { ++ for (Object tile : entityRemoval) ++ { ++ ((TileEntity)tile).onChunkUnload(); ++ } + this.loadedTileEntityList.removeAll(this.entityRemoval); + this.entityRemoval.clear(); + } +@@ -1892,7 +1919,9 @@ + { + this.loadedTileEntityList.add(var9); + } +- ++ } ++ else ++ { + if (this.chunkExists(var9.xCoord >> 4, var9.zCoord >> 4)) + { + Chunk var10 = this.getChunkFromChunkCoords(var9.xCoord >> 4, var9.zCoord >> 4); +@@ -1902,8 +1931,6 @@ + var10.setChunkBlockTileEntity(var9.xCoord & 15, var9.yCoord, var9.zCoord & 15, var9); + } + } +- +- this.markBlockNeedsUpdate(var9.xCoord, var9.yCoord, var9.zCoord); + } + } + +@@ -1916,13 +1943,13 @@ + + public void addTileEntity(Collection par1Collection) + { +- if (this.scanningTileEntities) +- { +- this.addedTileEntityList.addAll(par1Collection); +- } +- else +- { +- this.loadedTileEntityList.addAll(par1Collection); ++ List dest = scanningTileEntities ? addedTileEntityList : loadedTileEntityList; ++ for(Object entity : par1Collection) ++ { ++ if(((TileEntity)entity).canUpdate()) ++ { ++ dest.add(entity); ++ } + } + } + +@@ -1943,8 +1970,14 @@ + int var3 = MathHelper.floor_double(par1Entity.posX); + int var4 = MathHelper.floor_double(par1Entity.posZ); + byte var5 = 32; +- +- if (!par2 || this.checkChunksExist(var3 - var5, 0, var4 - var5, var3 + var5, 0, var4 + var5)) ++ boolean canUpdate = !par2 || this.checkChunksExist(var3 - var5, 0, var4 - var5, var3 + var5, 0, var4 + var5); ++ if (!canUpdate) ++ { ++ EntityEvent.CanUpdate event = new EntityEvent.CanUpdate(par1Entity); ++ MinecraftForge.EVENT_BUS.post(event); ++ canUpdate = event.canUpdate; ++ } ++ if (canUpdate) + { + par1Entity.lastTickPosX = par1Entity.posX; + par1Entity.lastTickPosY = par1Entity.posY; +@@ -2179,6 +2212,14 @@ + { + return true; + } ++ else ++ { ++ Block block = Block.blocksList[var11]; ++ if (block != null && block.isBlockBurning(this, var8, var9, var10)) ++ { ++ return true; ++ } ++ } + } + } + } +@@ -2481,25 +2522,21 @@ + */ + public void setBlockTileEntity(int par1, int par2, int par3, TileEntity par4TileEntity) + { +- if (par4TileEntity != null && !par4TileEntity.isInvalid()) +- { +- if (this.scanningTileEntities) +- { +- par4TileEntity.xCoord = par1; +- par4TileEntity.yCoord = par2; +- par4TileEntity.zCoord = par3; +- this.addedTileEntityList.add(par4TileEntity); +- } +- else +- { +- this.loadedTileEntityList.add(par4TileEntity); +- Chunk var5 = this.getChunkFromChunkCoords(par1 >> 4, par3 >> 4); +- +- if (var5 != null) +- { +- var5.setChunkBlockTileEntity(par1 & 15, par2, par3 & 15, par4TileEntity); +- } +- } ++ if (par4TileEntity == null || par4TileEntity.isInvalid()) ++ { ++ return; ++ } ++ ++ if (par4TileEntity.canUpdate()) ++ { ++ List dest = scanningTileEntities ? addedTileEntityList : loadedTileEntityList; ++ dest.add(par4TileEntity); ++ } ++ ++ Chunk chunk = getChunkFromChunkCoords(par1 >> 4, par3 >> 4); ++ if (chunk != null) ++ { ++ chunk.setChunkBlockTileEntity(par1 & 15, par2, par3 & 15, par4TileEntity); + } + } + +@@ -2508,27 +2545,10 @@ + */ + public void removeBlockTileEntity(int par1, int par2, int par3) + { +- TileEntity var4 = this.getBlockTileEntity(par1, par2, par3); +- +- if (var4 != null && this.scanningTileEntities) +- { +- var4.invalidate(); +- this.addedTileEntityList.remove(var4); +- } +- else +- { +- if (var4 != null) +- { +- this.addedTileEntityList.remove(var4); +- this.loadedTileEntityList.remove(var4); +- } +- +- Chunk var5 = this.getChunkFromChunkCoords(par1 >> 4, par3 >> 4); +- +- if (var5 != null) +- { +- var5.removeChunkBlockTileEntity(par1 & 15, par2, par3 & 15); +- } ++ Chunk chunk = getChunkFromChunkCoords(par1 >> 4, par3 >> 4); ++ if (chunk != null) ++ { ++ chunk.removeChunkBlockTileEntity(par1 & 15, par2, par3 & 15); + } + } + +@@ -2554,7 +2574,8 @@ + */ + public boolean isBlockNormalCube(int par1, int par2, int par3) + { +- return Block.isNormalCube(this.getBlockId(par1, par2, par3)); ++ Block block = Block.blocksList[getBlockId(par1, par2, par3)]; ++ return block != null && block.isBlockNormalCube(this, par1, par2, par3); + } + + /** +@@ -2562,8 +2583,7 @@ */ public boolean doesBlockHaveSolidTopSurface(int par1, int par2, int par3) { @@ -38,7 +266,66 @@ } /** -@@ -3917,4 +3926,65 @@ +@@ -2579,7 +2599,7 @@ + if (var5 != null && !var5.isEmpty()) + { + Block var6 = Block.blocksList[this.getBlockId(par1, par2, par3)]; +- return var6 == null ? false : var6.blockMaterial.isOpaque() && var6.renderAsNormalBlock(); ++ return var6 == null ? false : isBlockNormalCube(par1, par2, par3); + } + else + { +@@ -3006,7 +3026,7 @@ + + private int computeBlockLightValue(int par1, int par2, int par3, int par4, int par5, int par6) + { +- int var7 = Block.lightValue[par5]; ++ int var7 = (par5 == 0 || Block.blocksList[par5] == null ? 0 : Block.blocksList[par5].getLightValue(this, par2, par3, par4));; + int var8 = this.getSavedLightValue(EnumSkyBlock.Block, par2 - 1, par3, par4) - par6; + int var9 = this.getSavedLightValue(EnumSkyBlock.Block, par2 + 1, par3, par4) - par6; + int var10 = this.getSavedLightValue(EnumSkyBlock.Block, par2, par3 - 1, par4) - par6; +@@ -3274,10 +3294,10 @@ + public List getEntitiesWithinAABBExcludingEntity(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB) + { + this.entitiesWithinAABBExcludingEntity.clear(); +- int var3 = MathHelper.floor_double((par2AxisAlignedBB.minX - 2.0D) / 16.0D); +- int var4 = MathHelper.floor_double((par2AxisAlignedBB.maxX + 2.0D) / 16.0D); +- int var5 = MathHelper.floor_double((par2AxisAlignedBB.minZ - 2.0D) / 16.0D); +- int var6 = MathHelper.floor_double((par2AxisAlignedBB.maxZ + 2.0D) / 16.0D); ++ int var3 = MathHelper.floor_double((par2AxisAlignedBB.minX - MAX_ENTITY_RADIUS) / 16.0D); ++ int var4 = MathHelper.floor_double((par2AxisAlignedBB.maxX + MAX_ENTITY_RADIUS) / 16.0D); ++ int var5 = MathHelper.floor_double((par2AxisAlignedBB.minZ - MAX_ENTITY_RADIUS) / 16.0D); ++ int var6 = MathHelper.floor_double((par2AxisAlignedBB.maxZ + MAX_ENTITY_RADIUS) / 16.0D); + + for (int var7 = var3; var7 <= var4; ++var7) + { +@@ -3298,10 +3318,10 @@ + */ + public List getEntitiesWithinAABB(Class par1Class, AxisAlignedBB par2AxisAlignedBB) + { +- int var3 = MathHelper.floor_double((par2AxisAlignedBB.minX - 2.0D) / 16.0D); +- int var4 = MathHelper.floor_double((par2AxisAlignedBB.maxX + 2.0D) / 16.0D); +- int var5 = MathHelper.floor_double((par2AxisAlignedBB.minZ - 2.0D) / 16.0D); +- int var6 = MathHelper.floor_double((par2AxisAlignedBB.maxZ + 2.0D) / 16.0D); ++ int var3 = MathHelper.floor_double((par2AxisAlignedBB.minX - MAX_ENTITY_RADIUS) / 16.0D); ++ int var4 = MathHelper.floor_double((par2AxisAlignedBB.maxX + MAX_ENTITY_RADIUS) / 16.0D); ++ int var5 = MathHelper.floor_double((par2AxisAlignedBB.minZ - MAX_ENTITY_RADIUS) / 16.0D); ++ int var6 = MathHelper.floor_double((par2AxisAlignedBB.maxZ + MAX_ENTITY_RADIUS) / 16.0D); + ArrayList var7 = new ArrayList(); + + for (int var8 = var3; var8 <= var4; ++var8) +@@ -3430,6 +3450,10 @@ + var9 = null; + } + ++ if (var9 != null && var9.isBlockReplaceable(this, par2, par3, par4)) ++ { ++ var9 = null; ++ } + return par1 > 0 && var9 == null && var10.canPlaceBlockOnSide(this, par2, par3, par4, par6); + } + } +@@ -3917,4 +3941,65 @@ var7.destroyBlockPartially(par1, par2, par3, par4, par5); } } diff --git a/patches/minecraft/net/minecraft/src/WorldServer.java.patch b/patches/minecraft/net/minecraft/src/WorldServer.java.patch new file mode 100644 index 000000000..807f5ae9e --- /dev/null +++ b/patches/minecraft/net/minecraft/src/WorldServer.java.patch @@ -0,0 +1,19 @@ +--- ../src_base/minecraft/net/minecraft/src/WorldServer.java ++++ ../src_work/minecraft/net/minecraft/src/WorldServer.java +@@ -8,6 +8,8 @@ + import java.util.Set; + import java.util.TreeSet; + import net.minecraft.server.MinecraftServer; ++import net.minecraftforge.common.MinecraftForge; ++import net.minecraftforge.event.world.WorldEvent; + + public class WorldServer extends World + { +@@ -685,6 +687,7 @@ + } + + this.chunkProvider.saveChunks(par1, par2IProgressUpdate); ++ MinecraftForge.EVENT_BUS.post(new WorldEvent.Save(this)); + } + } +