diff --git a/common/net/minecraftforge/common/ForgeHooks.java b/common/net/minecraftforge/common/ForgeHooks.java index baffa8074..8e1a09aa3 100644 --- a/common/net/minecraftforge/common/ForgeHooks.java +++ b/common/net/minecraftforge/common/ForgeHooks.java @@ -61,17 +61,19 @@ public class ForgeHooks { return true; } + ItemStack stack = player.inventory.getCurrentItem(); if (stack == null) { return player.canHarvestBlock(block); } - List info = (List)toolClasses.get(stack); + List info = (List)toolClasses.get(stack.getItem()); if (info == null) { return player.canHarvestBlock(block); } + Object[] tmp = info.toArray(); String toolClass = (String)tmp[0]; int harvestLevel = (Integer)tmp[1]; @@ -81,6 +83,7 @@ public class ForgeHooks { return player.canHarvestBlock(block); } + if (blockHarvestLevel > harvestLevel) { return false; @@ -103,7 +106,7 @@ public class ForgeHooks } else { - return player.getCurrentPlayerStrVsBlock(block, metadata) / hardness / 30F; + return player.getCurrentPlayerStrVsBlock(block, metadata) / hardness / 30F; } } @@ -143,21 +146,6 @@ public class ForgeHooks MinecraftForge.setToolClass(Item.shovelGold, "shovel", 0); MinecraftForge.setToolClass(Item.shovelDiamond, "shovel", 3); - MinecraftForge.setBlockHarvestLevel(Block.obsidian, "pickaxe", 3); - MinecraftForge.setBlockHarvestLevel(Block.oreDiamond, "pickaxe", 2); - MinecraftForge.setBlockHarvestLevel(Block.blockDiamond, "pickaxe", 2); - MinecraftForge.setBlockHarvestLevel(Block.oreGold, "pickaxe", 2); - MinecraftForge.setBlockHarvestLevel(Block.blockGold, "pickaxe", 2); - MinecraftForge.setBlockHarvestLevel(Block.oreIron, "pickaxe", 1); - MinecraftForge.setBlockHarvestLevel(Block.blockSteel, "pickaxe", 1); - MinecraftForge.setBlockHarvestLevel(Block.oreLapis, "pickaxe", 1); - MinecraftForge.setBlockHarvestLevel(Block.blockLapis, "pickaxe", 1); - MinecraftForge.setBlockHarvestLevel(Block.oreRedstone, "pickaxe", 2); - MinecraftForge.setBlockHarvestLevel(Block.oreRedstoneGlowing, "pickaxe", 2); - MinecraftForge.removeBlockEffectiveness(Block.oreRedstone, "pickaxe"); - MinecraftForge.removeBlockEffectiveness(Block.obsidian, "pickaxe"); - MinecraftForge.removeBlockEffectiveness(Block.oreRedstoneGlowing, "pickaxe"); - for (Block block : ItemPickaxe.blocksEffectiveAgainst) { MinecraftForge.setBlockHarvestLevel(block, "pickaxe", 0); @@ -173,6 +161,21 @@ public class ForgeHooks MinecraftForge.setBlockHarvestLevel(block, "axe", 0); } + MinecraftForge.setBlockHarvestLevel(Block.obsidian, "pickaxe", 3); + MinecraftForge.setBlockHarvestLevel(Block.oreEmerald, "pickaxe", 2); + MinecraftForge.setBlockHarvestLevel(Block.oreDiamond, "pickaxe", 2); + MinecraftForge.setBlockHarvestLevel(Block.blockDiamond, "pickaxe", 2); + MinecraftForge.setBlockHarvestLevel(Block.oreGold, "pickaxe", 2); + MinecraftForge.setBlockHarvestLevel(Block.blockGold, "pickaxe", 2); + MinecraftForge.setBlockHarvestLevel(Block.oreIron, "pickaxe", 1); + MinecraftForge.setBlockHarvestLevel(Block.blockSteel, "pickaxe", 1); + MinecraftForge.setBlockHarvestLevel(Block.oreLapis, "pickaxe", 1); + MinecraftForge.setBlockHarvestLevel(Block.blockLapis, "pickaxe", 1); + MinecraftForge.setBlockHarvestLevel(Block.oreRedstone, "pickaxe", 2); + MinecraftForge.setBlockHarvestLevel(Block.oreRedstoneGlowing, "pickaxe", 2); + MinecraftForge.removeBlockEffectiveness(Block.oreRedstone, "pickaxe"); + MinecraftForge.removeBlockEffectiveness(Block.obsidian, "pickaxe"); + MinecraftForge.removeBlockEffectiveness(Block.oreRedstoneGlowing, "pickaxe"); } public static String getTexture(String _default, Object obj) @@ -219,11 +222,6 @@ public class ForgeHooks ModLoader.getLogger().info(String.format("MinecraftForge v%s Initialized", ForgeVersion.getVersion())); } - public static boolean onEntityInteract(EntityPlayer entityPlayer, Entity par1Entity, boolean b) - { - return false; - } - /** * Called when a player uses 'pick block', calls new Entity and Block hooks. */ diff --git a/common/net/minecraftforge/event/entity/player/EntityInteractEvent.java b/common/net/minecraftforge/event/entity/player/EntityInteractEvent.java new file mode 100644 index 000000000..c1c0c2eec --- /dev/null +++ b/common/net/minecraftforge/event/entity/player/EntityInteractEvent.java @@ -0,0 +1,16 @@ +package net.minecraftforge.event.entity.player; + +import net.minecraft.src.Entity; +import net.minecraft.src.EntityPlayer; +import net.minecraftforge.event.Cancelable; + +@Cancelable +public class EntityInteractEvent extends PlayerEvent +{ + public final Entity target; + public EntityInteractEvent(EntityPlayer player, Entity target) + { + super(player); + this.target = target; + } +} diff --git a/fml-src-3.0.5.239.zip b/fml-src-3.0.9.242.zip similarity index 95% rename from fml-src-3.0.5.239.zip rename to fml-src-3.0.9.242.zip index 7c494d476..9ff8c61c4 100644 Binary files a/fml-src-3.0.5.239.zip and b/fml-src-3.0.9.242.zip differ diff --git a/patches/common/net/minecraft/src/EntityPlayer.java.patch b/patches/common/net/minecraft/src/EntityPlayer.java.patch index 5d09d659d..06a50836c 100644 --- a/patches/common/net/minecraft/src/EntityPlayer.java.patch +++ b/patches/common/net/minecraft/src/EntityPlayer.java.patch @@ -1,6 +1,6 @@ --- ../src_base/common/net/minecraft/src/EntityPlayer.java +++ ../src_work/common/net/minecraft/src/EntityPlayer.java -@@ -7,6 +7,14 @@ +@@ -7,6 +7,15 @@ import java.util.Iterator; import java.util.List; @@ -10,12 +10,13 @@ +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingHurtEvent; +import net.minecraftforge.event.entity.player.AttackEntityEvent; ++import net.minecraftforge.event.entity.player.EntityInteractEvent; +import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; +import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; public abstract class EntityPlayer extends EntityLiving implements ICommandSender { -@@ -222,6 +230,7 @@ +@@ -222,6 +231,7 @@ if (var1 == this.itemInUse) { @@ -23,7 +24,7 @@ if (this.itemInUseCount <= 25 && this.itemInUseCount % 4 == 0) { this.updateItemUse(var1, 5); -@@ -627,7 +636,16 @@ +@@ -627,7 +637,16 @@ */ public EntityItem dropOneItem() { @@ -41,7 +42,7 @@ } /** -@@ -693,13 +711,21 @@ +@@ -693,13 +712,21 @@ /** * Returns how strong the player is against the specified block at this moment @@ -66,7 +67,7 @@ { var2 += (float)(var3 * var3 + 1); } -@@ -992,12 +1018,23 @@ +@@ -992,12 +1019,23 @@ */ protected void damageEntity(DamageSource par1DamageSource, int par2) { @@ -91,18 +92,18 @@ par2 = this.applyPotionDamageCalculations(par1DamageSource, par2); this.addExhaustion(par1DamageSource.getHungerDamage()); this.health -= par2; -@@ -1032,6 +1069,10 @@ +@@ -1032,6 +1070,10 @@ public boolean interactWith(Entity par1Entity) { -+ if (!ForgeHooks.onEntityInteract(this, par1Entity, false)) ++ if (MinecraftForge.EVENT_BUS.post(new EntityInteractEvent(this, par1Entity))) + { + return false; + } if (par1Entity.interact(this)) { return true; -@@ -1075,7 +1116,9 @@ +@@ -1075,7 +1117,9 @@ */ public void destroyCurrentEquippedItem() { @@ -112,7 +113,7 @@ } /** -@@ -1104,6 +1147,15 @@ +@@ -1104,6 +1148,15 @@ */ public void attackTargetEntityWithCurrentItem(Entity par1Entity) { @@ -128,7 +129,7 @@ if (par1Entity.canAttackWithItem()) { int var2 = this.inventory.getDamageVsEntity(par1Entity); -@@ -1247,6 +1299,12 @@ +@@ -1247,6 +1300,12 @@ */ public EnumStatus sleepInBedAt(int par1, int par2, int par3) { @@ -141,7 +142,7 @@ if (!this.worldObj.isRemote) { if (this.isPlayerSleeping() || !this.isEntityAlive()) -@@ -1286,6 +1344,11 @@ +@@ -1286,6 +1345,11 @@ { int var9 = this.worldObj.getBlockMetadata(par1, par2, par3); int var5 = BlockBed.getDirection(var9); @@ -153,7 +154,7 @@ float var10 = 0.5F; float var7 = 0.5F; -@@ -1356,10 +1419,12 @@ +@@ -1356,10 +1420,12 @@ ChunkCoordinates var4 = this.playerLocation; ChunkCoordinates var5 = this.playerLocation; @@ -170,7 +171,7 @@ if (var5 == null) { -@@ -1396,7 +1461,9 @@ +@@ -1396,7 +1462,9 @@ */ private boolean isInBed() { @@ -181,7 +182,7 @@ } /** -@@ -1411,13 +1478,15 @@ +@@ -1411,13 +1479,15 @@ var2.loadChunk(par1ChunkCoordinates.posX - 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4); var2.loadChunk(par1ChunkCoordinates.posX + 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4); @@ -199,7 +200,7 @@ return var3; } } -@@ -1431,8 +1500,11 @@ +@@ -1431,8 +1501,11 @@ { if (this.playerLocation != null) { @@ -213,7 +214,7 @@ switch (var2) { -@@ -1725,6 +1797,7 @@ +@@ -1725,6 +1798,7 @@ return 101; } } diff --git a/patches/common/net/minecraft/src/Item.java.patch b/patches/common/net/minecraft/src/Item.java.patch index a840f6bce..30105bead 100644 --- a/patches/common/net/minecraft/src/Item.java.patch +++ b/patches/common/net/minecraft/src/Item.java.patch @@ -18,7 +18,18 @@ } itemsList[256 + par1] = this; -@@ -650,4 +653,185 @@ +@@ -589,6 +592,10 @@ + float var18 = var15 * var16; + float var20 = var14 * var16; + double var21 = 5.0D; ++ if (par2EntityPlayer instanceof EntityPlayerMP) ++ { ++ var21 = ((EntityPlayerMP)par2EntityPlayer).theItemInWorldManager.getBlockReachDistance(); ++ } + Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21); + return par1World.rayTraceBlocks_do_do(var13, var23, par3, !par3); + } +@@ -650,4 +657,185 @@ { StatList.initStats(); } diff --git a/patches/common/net/minecraft/src/ItemInWorldManager.java.patch b/patches/common/net/minecraft/src/ItemInWorldManager.java.patch new file mode 100644 index 000000000..5ba7383d7 --- /dev/null +++ b/patches/common/net/minecraft/src/ItemInWorldManager.java.patch @@ -0,0 +1,114 @@ +--- ../src_base/common/net/minecraft/src/ItemInWorldManager.java ++++ ../src_work/common/net/minecraft/src/ItemInWorldManager.java +@@ -1,7 +1,13 @@ + package net.minecraft.src; ++ ++import net.minecraftforge.common.ForgeHooks; ++import net.minecraftforge.common.MinecraftForge; ++import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; + + public class ItemInWorldManager + { ++ /** Forge reach distance */ ++ private double blockReachDistance = 5.0d; + /** The world object that this object is connected to. */ + public World theWorld; + +@@ -222,7 +228,7 @@ + var4.onBlockHarvested(this.theWorld, par1, par2, par3, var5, this.thisPlayerMP); + } + +- boolean var6 = this.theWorld.setBlockWithNotify(par1, par2, par3, 0); ++ boolean var6 = (var4 != null && var4.removeBlockByPlayer(theWorld, thisPlayerMP, par1, par2, par3)); + + if (var4 != null && var6) + { +@@ -246,16 +252,22 @@ + int var4 = this.theWorld.getBlockId(par1, par2, par3); + int var5 = this.theWorld.getBlockMetadata(par1, par2, par3); + this.theWorld.playAuxSFXAtEntity(this.thisPlayerMP, 2001, par1, par2, par3, var4 + (this.theWorld.getBlockMetadata(par1, par2, par3) << 12)); +- boolean var6 = this.removeBlock(par1, par2, par3); ++ boolean var6 = false; + + if (this.isCreative()) + { ++ var6 = this.removeBlock(par1, par2, par3); + this.thisPlayerMP.serverForThisPlayer.sendPacketToPlayer(new Packet53BlockChange(par1, par2, par3, this.theWorld)); + } + else + { + ItemStack var7 = this.thisPlayerMP.getCurrentEquippedItem(); +- boolean var8 = this.thisPlayerMP.canHarvestBlock(Block.blocksList[var4]); ++ boolean var8 = false; ++ Block block = Block.blocksList[var4]; ++ if (block != null) ++ { ++ var8 = block.canHarvestBlock(thisPlayerMP, var5); ++ } + + if (var7 != null) + { +@@ -264,9 +276,11 @@ + if (var7.stackSize == 0) + { + this.thisPlayerMP.destroyCurrentEquippedItem(); ++ MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thisPlayerMP, var7)); + } + } + ++ var6 = this.removeBlock(par1, par2, par3); + if (var6 && var8) + { + Block.blocksList[var4].harvestBlock(this.theWorld, this.thisPlayerMP, par1, par2, par3, var5); +@@ -303,6 +317,7 @@ + if (var6.stackSize == 0) + { + par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = null; ++ MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thisPlayerMP, var6)); + } + + return true; +@@ -315,6 +330,12 @@ + */ + public boolean activateBlockOrUseItem(EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { ++ if (par3ItemStack != null && ++ par3ItemStack.getItem() != null && ++ par3ItemStack.getItem().onItemUseFirst(par3ItemStack, par1EntityPlayer, par2World, par4, par5, par6, par7)) ++ { ++ return true; ++ } + int var11 = par2World.getBlockId(par4, par5, par6); + + if (var11 > 0 && Block.blocksList[var11].onBlockActivated(par2World, par4, par5, par6, par1EntityPlayer, par7, par8, par9, par10)) +@@ -336,7 +357,15 @@ + } + else + { +- return par3ItemStack.tryPlaceItemIntoWorld(par1EntityPlayer, par2World, par4, par5, par6, par7, par8, par9, par10); ++ if (!par3ItemStack.tryPlaceItemIntoWorld(par1EntityPlayer, par2World, par4, par5, par6, par7, par8, par9, par10)) ++ { ++ return false; ++ } ++ if (par3ItemStack.stackSize <= 0) ++ { ++ MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thisPlayerMP, par3ItemStack)); ++ } ++ return true; + } + } + +@@ -347,4 +376,13 @@ + { + this.theWorld = par1WorldServer; + } ++ ++ public double getBlockReachDistance() ++ { ++ return blockReachDistance; ++ } ++ public void setBlockReachDistance(double distance) ++ { ++ blockReachDistance = distance; ++ } + } diff --git a/patches/common/net/minecraft/src/NetServerHandler.java.patch b/patches/common/net/minecraft/src/NetServerHandler.java.patch new file mode 100644 index 000000000..ffd879a5e --- /dev/null +++ b/patches/common/net/minecraft/src/NetServerHandler.java.patch @@ -0,0 +1,34 @@ +--- ../src_base/common/net/minecraft/src/NetServerHandler.java ++++ ../src_work/common/net/minecraft/src/NetServerHandler.java +@@ -383,7 +383,10 @@ + double var12 = this.playerEntity.posZ - ((double)var7 + 0.5D); + double var14 = var8 * var8 + var10 * var10 + var12 * var12; + +- if (var14 > 36.0D) ++ double dist = playerEntity.theItemInWorldManager.getBlockReachDistance() + 1; ++ dist *= dist; ++ ++ if (var14 > dist) + { + return; + } +@@ -405,7 +408,7 @@ + + if (par1Packet14BlockDig.status == 0) + { +- if (var20 <= 16 && !var3) ++ if (var20 <= mcServer.spawnProtectionSize && !var3) + { + this.playerEntity.serverForThisPlayer.sendPacketToPlayer(new Packet53BlockChange(var5, var6, var7, var2)); + } +@@ -485,7 +488,9 @@ + var12 = var11; + } + +- if (this.hasMoved && this.playerEntity.getDistanceSq((double)var5 + 0.5D, (double)var6 + 0.5D, (double)var7 + 0.5D) < 64.0D && (var12 > 16 || var9)) ++ double dist = playerEntity.theItemInWorldManager.getBlockReachDistance() + 1; ++ dist *= dist; ++ if (this.hasMoved && this.playerEntity.getDistanceSq((double)var5 + 0.5D, (double)var6 + 0.5D, (double)var7 + 0.5D) < dist && (var12 > mcServer.spawnProtectionSize || var9)) + { + this.playerEntity.theItemInWorldManager.activateBlockOrUseItem(this.playerEntity, var2, var3, var5, var6, var7, var8, par1Packet15Place.getXOffset(), par1Packet15Place.getYOffset(), par1Packet15Place.getZOffset()); + } diff --git a/patches/common/net/minecraft/src/WorldServer.java.patch b/patches/common/net/minecraft/src/WorldServer.java.patch index 8ca34d4f0..975b2e6f1 100644 --- a/patches/common/net/minecraft/src/WorldServer.java.patch +++ b/patches/common/net/minecraft/src/WorldServer.java.patch @@ -55,6 +55,15 @@ } } +@@ -566,7 +582,7 @@ + var6 = var5; + } + +- return var6 > 16 || this.mcServer.getConfigurationManager().areCommandsAllowed(par1EntityPlayer.username) || this.mcServer.isSinglePlayer(); ++ return var6 > mcServer.spawnProtectionSize || this.mcServer.getConfigurationManager().areCommandsAllowed(par1EntityPlayer.username) || this.mcServer.isSinglePlayer(); + } + + protected void initialize(WorldSettings par1WorldSettings) @@ -689,6 +705,7 @@ } diff --git a/patches/minecraft/net/minecraft/src/IntegratedServer.java.patch b/patches/minecraft/net/minecraft/src/IntegratedServer.java.patch index e079f6b2f..66b54c4ab 100644 --- a/patches/minecraft/net/minecraft/src/IntegratedServer.java.patch +++ b/patches/minecraft/net/minecraft/src/IntegratedServer.java.patch @@ -63,3 +63,11 @@ this.setDifficultyForAllDimensions(this.getDifficulty()); this.initialWorldChunkLoad(); } +@@ -101,6 +78,7 @@ + this.loadAllDimensions(this.getFolderName(), this.getWorldName(), this.field_71350_m.getSeed(), this.field_71350_m.getTerrainType()); + this.setMOTD(this.getServerOwner() + " - " + this.theWorldServer[0].getWorldInfo().getWorldName()); + FMLCommonHandler.instance().handleServerStarting(this); ++ spawnProtectionSize = 0; + return true; + } + diff --git a/patches/minecraft/net/minecraft/src/RenderItem.java.patch b/patches/minecraft/net/minecraft/src/RenderItem.java.patch index aff4bc287..c9e531cec 100644 --- a/patches/minecraft/net/minecraft/src/RenderItem.java.patch +++ b/patches/minecraft/net/minecraft/src/RenderItem.java.patch @@ -88,11 +88,15 @@ Block var15 = Block.blocksList[par3]; GL11.glPushMatrix(); GL11.glTranslatef((float)(par6 - 2), (float)(par7 + 3), -3.0F + this.zLevel); -@@ -225,7 +224,7 @@ +@@ -223,9 +222,9 @@ + if (Item.itemsList[par3].requiresMultipleRenderPasses()) + { GL11.glDisable(GL11.GL_LIGHTING); - par2RenderEngine.bindTexture(par2RenderEngine.getTexture("/gui/items.png")); - +- par2RenderEngine.bindTexture(par2RenderEngine.getTexture("/gui/items.png")); +- - for (var8 = 0; var8 <= 1; ++var8) ++ par2RenderEngine.bindTexture(par2RenderEngine.getTexture(Item.itemsList[par3].getTextureFile())); ++ + for (var8 = 0; var8 <= Item.itemsList[par3].getRenderPasses(par4); ++var8) { var9 = Item.itemsList[par3].getIconFromDamageForRenderPass(par4, var8);