From 0f25e6ec6b7e58f6e6e5cc5d64a9bcd5b19ad726 Mon Sep 17 00:00:00 2001 From: MachineMuse Date: Sat, 29 Jun 2013 04:34:50 -0600 Subject: [PATCH 01/19] Added tessellation methods to obj model, for ISBRH-friendliness --- .../client/model/obj/WavefrontObject.java | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/client/net/minecraftforge/client/model/obj/WavefrontObject.java b/client/net/minecraftforge/client/model/obj/WavefrontObject.java index 55603fbbba..35f287672a 100644 --- a/client/net/minecraftforge/client/model/obj/WavefrontObject.java +++ b/client/net/minecraftforge/client/model/obj/WavefrontObject.java @@ -169,13 +169,17 @@ public class WavefrontObject implements IModelCustom { tessellator.startDrawing(GL11.GL_TRIANGLES); } + tessellateAll(tessellator); + tessellator.draw(); + } + + public void tessellateAll(Tessellator tessellator) + { for (GroupObject groupObject : groupObjects) { groupObject.render(tessellator); } - - tessellator.draw(); } public void renderOnly(String... groupNames) @@ -192,6 +196,19 @@ public class WavefrontObject implements IModelCustom } } + public void tessellateOnly(Tessellator tessellator, String... groupNames) { + for (GroupObject groupObject : groupObjects) + { + for (String groupName : groupNames) + { + if (groupName.equalsIgnoreCase(groupObject.name)) + { + groupObject.render(tessellator); + } + } + } + } + public void renderPart(String partName) { for (GroupObject groupObject : groupObjects) @@ -203,6 +220,16 @@ public class WavefrontObject implements IModelCustom } } + public void tessellatePart(Tessellator tessellator, String partName) { + for (GroupObject groupObject : groupObjects) + { + if (partName.equalsIgnoreCase(groupObject.name)) + { + groupObject.render(tessellator); + } + } + } + public void renderAllExcept(String... excludedGroupNames) { for (GroupObject groupObject : groupObjects) @@ -217,6 +244,20 @@ public class WavefrontObject implements IModelCustom } } + public void tessellateAllExcept(Tessellator tessellator, String... excludedGroupNames) + { + for (GroupObject groupObject : groupObjects) + { + for (String excludedGroupName : excludedGroupNames) + { + if (!excludedGroupName.equalsIgnoreCase(groupObject.name)) + { + groupObject.render(tessellator); + } + } + } + } + private Vertex parseVertex(String line, int lineCount) throws ModelFormatException { Vertex vertex = null; From ca011729d36e2cbdc520d712ef1acdb98b950681 Mon Sep 17 00:00:00 2001 From: MachineMuse Date: Sat, 29 Jun 2013 23:24:03 -0600 Subject: [PATCH 02/19] Fixed both RenderAllExcept behaviours --- .../client/model/obj/WavefrontObject.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/client/net/minecraftforge/client/model/obj/WavefrontObject.java b/client/net/minecraftforge/client/model/obj/WavefrontObject.java index 35f287672a..a9ff77ea4c 100644 --- a/client/net/minecraftforge/client/model/obj/WavefrontObject.java +++ b/client/net/minecraftforge/client/model/obj/WavefrontObject.java @@ -232,29 +232,41 @@ public class WavefrontObject implements IModelCustom public void renderAllExcept(String... excludedGroupNames) { + boolean exclude; for (GroupObject groupObject : groupObjects) { + exclude=false; for (String excludedGroupName : excludedGroupNames) { - if (!excludedGroupName.equalsIgnoreCase(groupObject.name)) + if (excludedGroupName.equalsIgnoreCase(groupObject.name)) { - groupObject.render(); + exclude=true; } } + if(!exclude) + { + groupObject.render(); + } } } public void tessellateAllExcept(Tessellator tessellator, String... excludedGroupNames) { + boolean exclude; for (GroupObject groupObject : groupObjects) { + exclude=false; for (String excludedGroupName : excludedGroupNames) { - if (!excludedGroupName.equalsIgnoreCase(groupObject.name)) + if (excludedGroupName.equalsIgnoreCase(groupObject.name)) { - groupObject.render(tessellator); + exclude=true; } } + if(!exclude) + { + groupObject.render(tessellator); + } } } @@ -388,7 +400,7 @@ public class WavefrontObject implements IModelCustom face.vertices = new Vertex[tokens.length]; face.textureCoordinates = new TextureCoordinate[tokens.length]; face.vertexNormals = new Vertex[tokens.length]; - + for (int i = 0; i < tokens.length; ++i) { subTokens = tokens[i].split("/"); @@ -405,7 +417,7 @@ public class WavefrontObject implements IModelCustom { face.vertices = new Vertex[tokens.length]; face.textureCoordinates = new TextureCoordinate[tokens.length]; - + for (int i = 0; i < tokens.length; ++i) { subTokens = tokens[i].split("/"); @@ -421,7 +433,7 @@ public class WavefrontObject implements IModelCustom { face.vertices = new Vertex[tokens.length]; face.vertexNormals = new Vertex[tokens.length]; - + for (int i = 0; i < tokens.length; ++i) { subTokens = tokens[i].split("//"); @@ -436,7 +448,7 @@ public class WavefrontObject implements IModelCustom else if (isValidFace_V_Line(line)) { face.vertices = new Vertex[tokens.length]; - + for (int i = 0; i < tokens.length; ++i) { face.vertices[i] = vertices.get(Integer.parseInt(tokens[i]) - 1); From 2c9e11299e86f3ea27a9dba956965f63f4c78f63 Mon Sep 17 00:00:00 2001 From: RedmenNL Date: Wed, 26 Jun 2013 15:20:14 +0200 Subject: [PATCH 03/19] Added more render methods to IModelCustom interface. --- client/net/minecraftforge/client/model/IModelCustom.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/net/minecraftforge/client/model/IModelCustom.java b/client/net/minecraftforge/client/model/IModelCustom.java index 35b4c01eac..dce97e39e1 100644 --- a/client/net/minecraftforge/client/model/IModelCustom.java +++ b/client/net/minecraftforge/client/model/IModelCustom.java @@ -5,5 +5,7 @@ package net.minecraftforge.client.model; public interface IModelCustom { String getType(); void renderAll(); + void renderOnly(String... groupNames); void renderPart(String partName); + void renderAllExcept(String... excludedGroupNames); } From f78eba09fdb02c2b41e45e61cc66674366db1c27 Mon Sep 17 00:00:00 2001 From: jk-5 Date: Thu, 22 Aug 2013 13:04:04 +0200 Subject: [PATCH 04/19] Added GuiOpenEvent You can use this for a clean way to override guis, without needing an TickHandler to check if the gui you want to override is open and show your own gui Proper close check --- .../client/event/GuiOpenEvent.java | 22 +++++++ .../net/minecraft/client/Minecraft.java.patch | 65 +++++++++++++++---- 2 files changed, 76 insertions(+), 11 deletions(-) create mode 100644 client/net/minecraftforge/client/event/GuiOpenEvent.java diff --git a/client/net/minecraftforge/client/event/GuiOpenEvent.java b/client/net/minecraftforge/client/event/GuiOpenEvent.java new file mode 100644 index 0000000000..67fdb29e9c --- /dev/null +++ b/client/net/minecraftforge/client/event/GuiOpenEvent.java @@ -0,0 +1,22 @@ +package net.minecraftforge.client.event; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.event.Cancelable; +import net.minecraftforge.event.Event; + +/** + * This event is called before any Gui will open. + * If you don't want this to happen, cancel the event. + * If you want to override this Gui, simply set the gui variable to your own Gui. + * + * @author jk-5 + */ +@Cancelable +public class GuiOpenEvent extends Event +{ + public GuiScreen gui; + public GuiOpenEvent(GuiScreen gui) + { + this.gui = gui; + } +} diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 40114cc97d..fae3a32c09 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -1,11 +1,12 @@ --- ../src_base/minecraft/net/minecraft/client/Minecraft.java +++ ../src_work/minecraft/net/minecraft/client/Minecraft.java -@@ -137,6 +137,14 @@ +@@ -137,6 +137,15 @@ import com.google.common.collect.MapDifference; +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.client.GuiIngameForge; ++import net.minecraftforge.client.event.GuiOpenEvent; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.ForgeEventFactory; @@ -15,7 +16,7 @@ @SideOnly(Side.CLIENT) public class Minecraft implements IPlayerUsage { -@@ -416,7 +424,7 @@ +@@ -416,7 +425,7 @@ try { @@ -24,7 +25,7 @@ } catch (LWJGLException lwjglexception) { -@@ -497,7 +505,7 @@ +@@ -497,7 +506,7 @@ this.effectRenderer = new EffectRenderer(this.theWorld, this.renderEngine); FMLClientHandler.instance().finishMinecraftLoading(); this.checkGLError("Post startup"); @@ -33,7 +34,49 @@ if (this.serverName != null) { -@@ -1300,7 +1308,7 @@ +@@ -679,20 +688,30 @@ + */ + public void displayGuiScreen(GuiScreen par1GuiScreen) + { ++ this.statFileWriter.syncStats(); ++ ++ if (par1GuiScreen == null && this.theWorld == null) ++ { ++ par1GuiScreen = new GuiMainMenu(); ++ } ++ else if (par1GuiScreen == null && this.thePlayer.func_110143_aJ() <= 0.0F) ++ { ++ par1GuiScreen = new GuiGameOver(); ++ } ++ ++ GuiScreen old = this.currentScreen; ++ GuiOpenEvent event = new GuiOpenEvent(par1GuiScreen); ++ boolean canceled = MinecraftForge.EVENT_BUS.post(event); ++ if(old != null && old != this.currentScreen) ++ { ++ old.onGuiClosed(); ++ } ++ if(canceled) return; ++ par1GuiScreen = event.gui; ++ + if (this.currentScreen != null) + { + this.currentScreen.onGuiClosed(); +- } +- +- this.statFileWriter.syncStats(); +- +- if (par1GuiScreen == null && this.theWorld == null) +- { +- par1GuiScreen = new GuiMainMenu(); +- } +- else if (par1GuiScreen == null && this.thePlayer.func_110143_aJ() <= 0.0F) +- { +- par1GuiScreen = new GuiGameOver(); + } + + if (par1GuiScreen instanceof GuiMainMenu) +@@ -1300,7 +1319,7 @@ if (this.thePlayer.isCurrentToolAdventureModeExempt(j, k, l)) { @@ -42,7 +85,7 @@ this.thePlayer.swingItem(); } } -@@ -1366,7 +1374,8 @@ +@@ -1366,7 +1385,8 @@ { int j1 = itemstack != null ? itemstack.stackSize : 0; @@ -52,7 +95,7 @@ { flag = false; this.thePlayer.swingItem(); -@@ -1392,7 +1401,8 @@ +@@ -1392,7 +1412,8 @@ { ItemStack itemstack1 = this.thePlayer.inventory.getCurrentItem(); @@ -62,7 +105,7 @@ { this.entityRenderer.itemRenderer.resetEquippedProgress2(); } -@@ -2046,6 +2056,11 @@ +@@ -2046,6 +2067,11 @@ { this.statFileWriter.syncStats(); @@ -74,7 +117,7 @@ if (par1WorldClient == null) { NetClientHandler netclienthandler = this.getNetHandler(); -@@ -2063,6 +2078,18 @@ +@@ -2063,6 +2089,18 @@ if (this.theIntegratedServer != null) { this.theIntegratedServer.initiateShutdown(); @@ -93,7 +136,7 @@ } this.theIntegratedServer = null; -@@ -2236,107 +2263,12 @@ +@@ -2236,107 +2274,12 @@ if (this.objectMouseOver != null) { boolean flag = this.thePlayer.capabilities.isCreativeMode; @@ -205,7 +248,7 @@ if (flag) { -@@ -2419,11 +2351,18 @@ +@@ -2419,11 +2362,18 @@ par1PlayerUsageSnooper.addData("gl_max_texture_size", Integer.valueOf(getGLMaximumTextureSize())); } @@ -224,7 +267,7 @@ for (int i = 16384; i > 0; i >>= 1) { GL11.glTexImage2D(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_RGBA, i, i, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null); -@@ -2431,6 +2370,7 @@ +@@ -2431,6 +2381,7 @@ if (j != 0) { From cc96840aa83298dce54770b3905a8bbcf8f00757 Mon Sep 17 00:00:00 2001 From: Michael Hahn Date: Mon, 26 Aug 2013 12:21:31 -0500 Subject: [PATCH 05/19] capacity was not respected Updated to properly calculate the amount of free space in the tank before checking that against the amount of the resource. --- common/net/minecraftforge/fluids/ItemFluidContainer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/net/minecraftforge/fluids/ItemFluidContainer.java b/common/net/minecraftforge/fluids/ItemFluidContainer.java index e42703aa40..be615d3a10 100644 --- a/common/net/minecraftforge/fluids/ItemFluidContainer.java +++ b/common/net/minecraftforge/fluids/ItemFluidContainer.java @@ -106,7 +106,7 @@ public class ItemFluidContainer extends Item implements IFluidContainerItem return 0; } - int filled = capacity - resource.amount; + int filled = capacity - stack.amount; if (resource.amount < filled) { stack.amount += resource.amount; From 90be31ddc8fe6b7db6ee8ba62a0b7da301e700d9 Mon Sep 17 00:00:00 2001 From: robin Date: Wed, 28 Aug 2013 13:14:30 +0200 Subject: [PATCH 06/19] create french localization --- common/assets/forge/lang/fr_FR.lang | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 common/assets/forge/lang/fr_FR.lang diff --git a/common/assets/forge/lang/fr_FR.lang b/common/assets/forge/lang/fr_FR.lang new file mode 100644 index 0000000000..bd01daa94a --- /dev/null +++ b/common/assets/forge/lang/fr_FR.lang @@ -0,0 +1,5 @@ +commands.forge.usage=Utilisez /forge . Les sous-commandes sont tps, track +commands.forge.usage.tracking=Utilisez /forge track . Les types valides sont te (Tile Entities). La durée doit être inférieur à 60. +commands.forge.tps.summary=%s : Duré de tick : %d ms. TPS moyen : %d + +commands.forge.tracking.te.enabled=Trackage des Tile Entity activé pour %d secondes. \ No newline at end of file From 0e3037e85ded360939c56a108e5ef9836a236f9f Mon Sep 17 00:00:00 2001 From: MachineMuse Date: Tue, 3 Sep 2013 14:55:11 -0600 Subject: [PATCH 07/19] Added display name hook --- .../net/minecraftforge/event/ForgeEventFactory.java | 7 +++++++ .../event/entity/player/PlayerEvent.java | 12 ++++++++++++ .../minecraft/entity/player/EntityPlayer.java.patch | 9 +++++++++ 3 files changed, 28 insertions(+) diff --git a/common/net/minecraftforge/event/ForgeEventFactory.java b/common/net/minecraftforge/event/ForgeEventFactory.java index d67cbeddeb..8158c59d96 100644 --- a/common/net/minecraftforge/event/ForgeEventFactory.java +++ b/common/net/minecraftforge/event/ForgeEventFactory.java @@ -75,4 +75,11 @@ public class ForgeEventFactory MinecraftForge.EVENT_BUS.post(maxCanSpawnEvent); return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.maxPackSize : entity.getMaxSpawnedInChunk(); } + + public static String getPlayerDisplayName(EntityPlayer player, String username) + { + PlayerEvent.NameFormat event = new PlayerEvent.NameFormat(player, username); + MinecraftForge.EVENT_BUS.post(event); + return event.displayname; + } } diff --git a/common/net/minecraftforge/event/entity/player/PlayerEvent.java b/common/net/minecraftforge/event/entity/player/PlayerEvent.java index a63f074923..8100318de7 100644 --- a/common/net/minecraftforge/event/entity/player/PlayerEvent.java +++ b/common/net/minecraftforge/event/entity/player/PlayerEvent.java @@ -45,4 +45,16 @@ public class PlayerEvent extends LivingEvent this.newSpeed = original; } } + + public static class NameFormat extends PlayerEvent + { + public final String username; + public String displayname; + + public NameFormat(EntityPlayer player, String username) { + super(player); + this.username = username; + this.displayname = username; + } + } } diff --git a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch index a1d0e4a84f..d5fd44adc0 100644 --- a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch +++ b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch @@ -543,3 +543,12 @@ } @SideOnly(Side.CLIENT) +@@ -2235,7 +2438,7 @@ + */ + public String getTranslatedEntityName() + { +- return ScorePlayerTeam.formatPlayerName(this.getTeam(), this.username); ++ return ScorePlayerTeam.formatPlayerName(this.getTeam(), ForgeEventFactory.getPlayerDisplayName(this, this.username)); + } + + public void func_110149_m(float par1) From cb9c26d49cf431d76e3d62da339b14004fddfca8 Mon Sep 17 00:00:00 2001 From: MachineMuse Date: Wed, 4 Sep 2013 14:22:22 -0600 Subject: [PATCH 08/19] Memoization of display name result --- .../entity/player/EntityPlayer.java.patch | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch index d5fd44adc0..808e72395a 100644 --- a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch +++ b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch @@ -548,7 +548,30 @@ public String getTranslatedEntityName() { - return ScorePlayerTeam.formatPlayerName(this.getTeam(), this.username); -+ return ScorePlayerTeam.formatPlayerName(this.getTeam(), ForgeEventFactory.getPlayerDisplayName(this, this.username)); ++ return ScorePlayerTeam.formatPlayerName(this.getTeam(), this.getDisplayName()); } public void func_110149_m(float par1) +@@ -2257,4 +2460,22 @@ + { + FMLNetworkHandler.openGui(this, mod, modGuiId, world, x, y, z); + } ++ /** ++ * Forge-added fields ++ */ ++ private String displayname; ++ ++ public String getDisplayName() ++ { ++ if(this.displayname == null) ++ { ++ this.displayname = ForgeEventFactory.getPlayerDisplayName(this, this.username); ++ } ++ return this.displayname; ++ } ++ ++ public void refreshDisplayName() ++ { ++ this.displayname = ForgeEventFactory.getPlayerDisplayName(this, this.username); ++ } + } From e3e3ea54f954feb4d55a93a04b851de32d118ecb Mon Sep 17 00:00:00 2001 From: MachineMuse Date: Wed, 4 Sep 2013 15:00:04 -0600 Subject: [PATCH 09/19] Added mouse event --- .../client/ForgeHooksClient.java | 5 +++ .../client/event/MouseEvent.java | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 client/net/minecraftforge/client/event/MouseEvent.java diff --git a/client/net/minecraftforge/client/ForgeHooksClient.java b/client/net/minecraftforge/client/ForgeHooksClient.java index a49b48e8ca..a2c2b01031 100644 --- a/client/net/minecraftforge/client/ForgeHooksClient.java +++ b/client/net/minecraftforge/client/ForgeHooksClient.java @@ -6,6 +6,7 @@ import java.util.TreeSet; import javax.imageio.ImageIO; +import net.minecraftforge.client.event.MouseEvent; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; @@ -325,6 +326,10 @@ public class ForgeHooksClient } } + public static boolean postMouseEvent() { + return MinecraftForge.EVENT_BUS.post(new MouseEvent()); + } + /** * Initialization of Forge Renderers. */ diff --git a/client/net/minecraftforge/client/event/MouseEvent.java b/client/net/minecraftforge/client/event/MouseEvent.java new file mode 100644 index 0000000000..1c3a1df9fd --- /dev/null +++ b/client/net/minecraftforge/client/event/MouseEvent.java @@ -0,0 +1,32 @@ +package net.minecraftforge.client.event; + +import net.minecraftforge.event.Cancelable; +import net.minecraftforge.event.Event; +import org.lwjgl.input.Mouse; + +/** + * Author: MachineMuse (Claire Semple) + * Created: 2:46 PM, 9/4/13 + */ +@Cancelable +public class MouseEvent extends Event { + public final int x; + public final int y; + public final int dx; + public final int dy; + public final int dwheel; + public final int button; + public final boolean buttonstate; + public final long nanoseconds; + + public MouseEvent() { + this.x = Mouse.getEventX(); + this.y = Mouse.getEventY(); + this.dx = Mouse.getEventDX(); + this.dy = Mouse.getEventDY(); + this.dwheel = Mouse.getEventDWheel(); + this.button = Mouse.getEventButton(); + this.buttonstate = Mouse.getEventButtonState(); + this.nanoseconds = Mouse.getEventNanoseconds(); + } +} From ad09526bee27ebdbb44391668ca567839978b9c6 Mon Sep 17 00:00:00 2001 From: MachineMuse Date: Wed, 4 Sep 2013 15:05:29 -0600 Subject: [PATCH 10/19] inserted hook into Minecraft.java --- .../minecraft/net/minecraft/client/Minecraft.java.patch | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 40114cc97d..640810c51f 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -62,6 +62,15 @@ { this.entityRenderer.itemRenderer.resetEquippedProgress2(); } +@@ -1575,7 +1585,7 @@ + while (Mouse.next()) + { + i = Mouse.getEventButton(); +- ++ if (!ForgeHooksClient.postMouseEvent()) continue; + if (field_142025_a && i == 0 && (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157))) + { + i = 1; @@ -2046,6 +2056,11 @@ { this.statFileWriter.syncStats(); From 7a77b61ddd649f16c2731bee89f4f6043d658dad Mon Sep 17 00:00:00 2001 From: MachineMuse Date: Wed, 4 Sep 2013 15:27:45 -0600 Subject: [PATCH 11/19] fixed logic error --- patches/minecraft/net/minecraft/client/Minecraft.java.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 640810c51f..f60d3a38d1 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -67,7 +67,7 @@ { i = Mouse.getEventButton(); - -+ if (!ForgeHooksClient.postMouseEvent()) continue; ++ if (ForgeHooksClient.postMouseEvent()) continue; if (field_142025_a && i == 0 && (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157))) { i = 1; From 6cf8408752ac3061c8c8299cd0e8f882d4e2262c Mon Sep 17 00:00:00 2001 From: iChun Date: Thu, 5 Sep 2013 14:57:34 +0800 Subject: [PATCH 12/19] Fix player push out of blocks clientside being hardcoded and not based on entity size. Added player eyeHeight field to allow changeable eye heights of players rather than being hardcoded per player class as well as add a getDefaultEyeHeight function. --- .../entity/EntityOtherPlayerMP.java.patch | 61 ++++++++++++ .../client/entity/EntityPlayerSP.java.patch | 72 +++++++++++++- .../entity/player/EntityPlayer.java.patch | 99 +++++++++++++------ .../entity/player/EntityPlayerMP.java.patch | 35 ++++++- 4 files changed, 231 insertions(+), 36 deletions(-) create mode 100644 patches/minecraft/net/minecraft/client/entity/EntityOtherPlayerMP.java.patch diff --git a/patches/minecraft/net/minecraft/client/entity/EntityOtherPlayerMP.java.patch b/patches/minecraft/net/minecraft/client/entity/EntityOtherPlayerMP.java.patch new file mode 100644 index 0000000000..d7119a152f --- /dev/null +++ b/patches/minecraft/net/minecraft/client/entity/EntityOtherPlayerMP.java.patch @@ -0,0 +1,61 @@ +--- ../src_base/minecraft/net/minecraft/client/entity/EntityOtherPlayerMP.java ++++ ../src_work/minecraft/net/minecraft/client/entity/EntityOtherPlayerMP.java +@@ -170,29 +170,36 @@ + } + } + +- public float getEyeHeight() ++ public void sendChatToPlayer(ChatMessageComponent par1ChatMessageComponent) ++ { ++ Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(par1ChatMessageComponent.toStringWithFormatting(true)); ++ } ++ ++ /** ++ * Returns true if the command sender is allowed to use the given command. ++ */ ++ public boolean canCommandSenderUseCommand(int par1, String par2Str) ++ { ++ return false; ++ } ++ ++ /** ++ * Return the position for this command sender. ++ */ ++ public ChunkCoordinates getPlayerCoordinates() ++ { ++ return new ChunkCoordinates(MathHelper.floor_double(this.posX + 0.5D), MathHelper.floor_double(this.posY + 0.5D), MathHelper.floor_double(this.posZ + 0.5D)); ++ } ++ ++ /* ===================================== FORGE START =====================================*/ ++ ++ /** ++ * Returns the default eye height of the player ++ * @return player default eye height ++ */ ++ @Override ++ public float getDefaultEyeHeight() + { + return 1.82F; + } +- +- public void sendChatToPlayer(ChatMessageComponent par1ChatMessageComponent) +- { +- Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(par1ChatMessageComponent.toStringWithFormatting(true)); +- } +- +- /** +- * Returns true if the command sender is allowed to use the given command. +- */ +- public boolean canCommandSenderUseCommand(int par1, String par2Str) +- { +- return false; +- } +- +- /** +- * Return the position for this command sender. +- */ +- public ChunkCoordinates getPlayerCoordinates() +- { +- return new ChunkCoordinates(MathHelper.floor_double(this.posX + 0.5D), MathHelper.floor_double(this.posY + 0.5D), MathHelper.floor_double(this.posZ + 0.5D)); +- } + } diff --git a/patches/minecraft/net/minecraft/client/entity/EntityPlayerSP.java.patch b/patches/minecraft/net/minecraft/client/entity/EntityPlayerSP.java.patch index eb71fca162..e401b0df70 100644 --- a/patches/minecraft/net/minecraft/client/entity/EntityPlayerSP.java.patch +++ b/patches/minecraft/net/minecraft/client/entity/EntityPlayerSP.java.patch @@ -9,7 +9,77 @@ @SideOnly(Side.CLIENT) public class EntityPlayerSP extends AbstractClientPlayer -@@ -685,6 +687,12 @@ +@@ -570,18 +572,63 @@ + */ + protected boolean pushOutOfBlocks(double par1, double par3, double par5) + { ++ if (this.noClip) { return false; } + int i = MathHelper.floor_double(par1); + int j = MathHelper.floor_double(par3); + int k = MathHelper.floor_double(par5); + double d3 = par1 - (double)i; + double d4 = par5 - (double)k; + +- if (this.isBlockTranslucent(i, j, k) || this.isBlockTranslucent(i, j + 1, k)) +- { +- boolean flag = !this.isBlockTranslucent(i - 1, j, k) && !this.isBlockTranslucent(i - 1, j + 1, k); +- boolean flag1 = !this.isBlockTranslucent(i + 1, j, k) && !this.isBlockTranslucent(i + 1, j + 1, k); +- boolean flag2 = !this.isBlockTranslucent(i, j, k - 1) && !this.isBlockTranslucent(i, j + 1, k - 1); +- boolean flag3 = !this.isBlockTranslucent(i, j, k + 1) && !this.isBlockTranslucent(i, j + 1, k + 1); ++ int entHeight = Math.max(Math.round(this.height), 1); ++ ++ boolean inTranslucentBlock = true; ++ ++ for (int i1 = 0; i1 < entHeight; i1++) ++ { ++ if (!this.isBlockTranslucent(i, j + i1, k)) ++ { ++ inTranslucentBlock = false; ++ } ++ } ++ ++ if (inTranslucentBlock) ++ { ++ boolean flag = true; ++ boolean flag1 = true; ++ boolean flag2 = true; ++ boolean flag3 = true; ++ for (int i1 = 0; i1 < entHeight; i1++) ++ { ++ if(this.isBlockTranslucent(i - 1, j + i1, k)) ++ { ++ flag = false; ++ break; ++ } ++ } ++ for (int i1 = 0; i1 < entHeight; i1++) ++ { ++ if(this.isBlockTranslucent(i + 1, j + i1, k)) ++ { ++ flag1 = false; ++ break; ++ } ++ } ++ for (int i1 = 0; i1 < entHeight; i1++) ++ { ++ if(this.isBlockTranslucent(i, j + i1, k - 1)) ++ { ++ flag2 = false; ++ break; ++ } ++ } ++ for (int i1 = 0; i1 < entHeight; i1++) ++ { ++ if(this.isBlockTranslucent(i, j + i1, k + 1)) ++ { ++ flag3 = false; ++ break; ++ } ++ } + byte b0 = -1; + double d5 = 9999.0D; + +@@ -685,6 +732,12 @@ public void playSound(String par1Str, float par2, float par3) { diff --git a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch index 3247597b2e..da35bc4e10 100644 --- a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch +++ b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch @@ -48,7 +48,15 @@ /** Holds the coordinate of the player when enter a minecraft to ride. */ private ChunkCoordinates startMinecartRidingCoordinate; -@@ -267,6 +285,7 @@ +@@ -175,6 +193,7 @@ + this.setLocationAndAngles((double)chunkcoordinates.posX + 0.5D, (double)(chunkcoordinates.posY + 1), (double)chunkcoordinates.posZ + 0.5D, 0.0F, 0.0F); + this.field_70741_aB = 180.0F; + this.fireResistance = 20; ++ this.eyeHeight = this.getDefaultEyeHeight(); + } + + protected void applyEntityAttributes() +@@ -267,6 +286,7 @@ if (itemstack == this.itemInUse) { @@ -56,7 +64,7 @@ if (this.itemInUseCount <= 25 && this.itemInUseCount % 4 == 0) { this.updateItemUse(itemstack, 5); -@@ -429,7 +448,7 @@ +@@ -429,7 +449,7 @@ vec31.rotateAroundX(-this.rotationPitch * (float)Math.PI / 180.0F); vec31.rotateAroundY(-this.rotationYaw * (float)Math.PI / 180.0F); vec31 = vec31.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ); @@ -65,7 +73,7 @@ } this.playSound("random.eat", 0.5F + 0.5F * (float)this.rand.nextInt(2), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); -@@ -537,11 +556,11 @@ +@@ -537,11 +557,11 @@ this.cameraYaw = 0.0F; this.addMountedMovementStat(this.posX - d0, this.posY - d1, this.posZ - d2); @@ -79,7 +87,7 @@ } } } -@@ -684,11 +703,15 @@ +@@ -684,11 +704,15 @@ */ public void onDeath(DamageSource par1DamageSource) { @@ -95,7 +103,7 @@ if (this.username.equals("Notch")) { this.dropPlayerItemWithRandomChoice(new ItemStack(Item.appleRed, 1), true); -@@ -697,6 +720,20 @@ +@@ -697,6 +721,20 @@ if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) { this.inventory.dropAllItems(); @@ -116,7 +124,7 @@ } if (par1DamageSource != null) -@@ -747,7 +784,20 @@ +@@ -747,7 +785,20 @@ */ public EntityItem dropOneItem(boolean par1) { @@ -138,7 +146,7 @@ } /** -@@ -756,7 +806,7 @@ +@@ -756,7 +807,7 @@ */ public EntityItem dropPlayerItem(ItemStack par1ItemStack) { @@ -147,7 +155,7 @@ } /** -@@ -812,15 +862,28 @@ +@@ -812,15 +863,28 @@ */ public void joinEntityItemWithWorld(EntityItem par1EntityItem) { @@ -178,7 +186,7 @@ if (f > 1.0F) { -@@ -831,7 +894,9 @@ +@@ -831,7 +895,9 @@ { float f1 = (float)(i * i + 1); @@ -189,7 +197,7 @@ { f += f1 * 0.08F; } -@@ -862,7 +927,8 @@ +@@ -862,7 +928,8 @@ f /= 5.0F; } @@ -199,7 +207,7 @@ } /** -@@ -870,7 +936,7 @@ +@@ -870,7 +937,7 @@ */ public boolean canHarvestBlock(Block par1Block) { @@ -208,7 +216,7 @@ } /** -@@ -900,6 +966,14 @@ +@@ -900,6 +967,14 @@ this.spawnChunk = new ChunkCoordinates(par1NBTTagCompound.getInteger("SpawnX"), par1NBTTagCompound.getInteger("SpawnY"), par1NBTTagCompound.getInteger("SpawnZ")); this.spawnForced = par1NBTTagCompound.getBoolean("SpawnForced"); } @@ -223,7 +231,7 @@ this.foodStats.readNBT(par1NBTTagCompound); this.capabilities.readCapabilitiesFromNBT(par1NBTTagCompound); -@@ -933,6 +1007,21 @@ +@@ -933,6 +1008,21 @@ par1NBTTagCompound.setInteger("SpawnZ", this.spawnChunk.posZ); par1NBTTagCompound.setBoolean("SpawnForced", this.spawnForced); } @@ -245,7 +253,16 @@ this.foodStats.writeNBT(par1NBTTagCompound); this.capabilities.writeCapabilitiesToNBT(par1NBTTagCompound); -@@ -980,6 +1069,7 @@ +@@ -964,7 +1054,7 @@ + + public float getEyeHeight() + { +- return 0.12F; ++ return eyeHeight; + } + + /** +@@ -980,6 +1070,7 @@ */ public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { @@ -253,7 +270,7 @@ if (this.isEntityInvulnerable()) { return false; -@@ -1092,12 +1182,15 @@ +@@ -1092,12 +1183,15 @@ { if (!this.isEntityInvulnerable()) { @@ -270,7 +287,7 @@ par2 = this.applyPotionDamageCalculations(par1DamageSource, par2); float f1 = par2; par2 = Math.max(par2 - this.getAbsorptionAmount(), 0.0F); -@@ -1147,6 +1240,7 @@ +@@ -1147,6 +1241,7 @@ public boolean interactWith(Entity par1Entity) { @@ -278,7 +295,7 @@ ItemStack itemstack = this.getCurrentEquippedItem(); ItemStack itemstack1 = itemstack != null ? itemstack.copy() : null; -@@ -1203,7 +1297,9 @@ +@@ -1203,7 +1298,9 @@ */ public void destroyCurrentEquippedItem() { @@ -288,7 +305,7 @@ } /** -@@ -1220,6 +1316,15 @@ +@@ -1220,6 +1317,15 @@ */ public void attackTargetEntityWithCurrentItem(Entity par1Entity) { @@ -304,7 +321,7 @@ if (par1Entity.canAttackWithItem()) { if (!par1Entity.hitByEntity(this)) -@@ -1373,6 +1478,12 @@ +@@ -1373,6 +1479,12 @@ */ public EnumStatus sleepInBedAt(int par1, int par2, int par3) { @@ -317,7 +334,7 @@ if (!this.worldObj.isRemote) { if (this.isPlayerSleeping() || !this.isEntityAlive()) -@@ -1417,6 +1528,11 @@ +@@ -1417,6 +1529,11 @@ { int l = this.worldObj.getBlockMetadata(par1, par2, par3); int i1 = BlockBed.getDirection(l); @@ -329,7 +346,7 @@ float f = 0.5F; float f1 = 0.5F; -@@ -1487,10 +1603,12 @@ +@@ -1487,10 +1604,12 @@ ChunkCoordinates chunkcoordinates = this.playerLocation; ChunkCoordinates chunkcoordinates1 = this.playerLocation; @@ -346,7 +363,7 @@ if (chunkcoordinates1 == null) { -@@ -1527,7 +1645,9 @@ +@@ -1527,7 +1646,9 @@ */ private boolean isInBed() { @@ -357,7 +374,7 @@ } /** -@@ -1542,9 +1662,12 @@ +@@ -1542,9 +1663,12 @@ ichunkprovider.loadChunk(par1ChunkCoordinates.posX - 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4); ichunkprovider.loadChunk(par1ChunkCoordinates.posX + 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4); @@ -373,7 +390,7 @@ return chunkcoordinates1; } else -@@ -1566,10 +1689,13 @@ +@@ -1566,10 +1690,13 @@ { if (this.playerLocation != null) { @@ -391,7 +408,7 @@ { case 0: return 90.0F; -@@ -1635,14 +1761,40 @@ +@@ -1635,14 +1762,40 @@ /** * Returns the location of the bed the player will respawn at, or null if the player has not slept in a bed. */ @@ -436,7 +453,7 @@ } /** -@@ -1650,6 +1802,10 @@ +@@ -1650,6 +1803,10 @@ */ public void setSpawnChunk(ChunkCoordinates par1ChunkCoordinates, boolean par2) { @@ -447,7 +464,7 @@ if (par1ChunkCoordinates != null) { this.spawnChunk = new ChunkCoordinates(par1ChunkCoordinates); -@@ -1661,7 +1817,32 @@ +@@ -1661,7 +1818,32 @@ this.spawnForced = false; } } @@ -481,7 +498,7 @@ /** * Will trigger the specified trigger. */ -@@ -1843,6 +2024,10 @@ +@@ -1843,6 +2025,10 @@ super.fall(par1); } @@ -492,7 +509,7 @@ } /** -@@ -1884,7 +2069,7 @@ +@@ -1884,7 +2070,7 @@ { if (par1ItemStack.getItem().requiresMultipleRenderPasses()) { @@ -501,7 +518,7 @@ } if (this.itemInUse != null && par1ItemStack.itemID == Item.bow.itemID) -@@ -1906,6 +2091,7 @@ +@@ -1906,6 +2092,7 @@ return Item.bow.getItemIconForUseDuration(0); } } @@ -509,7 +526,7 @@ } return icon; -@@ -2127,7 +2313,17 @@ +@@ -2127,7 +2314,17 @@ this.setScore(par1EntityPlayer.getScore()); } @@ -527,7 +544,7 @@ } /** -@@ -2191,7 +2387,14 @@ +@@ -2191,7 +2388,14 @@ */ public void setCurrentItemOrArmor(int par1, ItemStack par2ItemStack) { @@ -543,3 +560,21 @@ } @SideOnly(Side.CLIENT) +@@ -2267,4 +2471,17 @@ + { + FMLNetworkHandler.openGui(this, mod, modGuiId, world, x, y, z); + } ++ ++ /* ===================================== FORGE START =====================================*/ ++ ++ public float eyeHeight; ++ ++ /** ++ * Returns the default eye height of the player ++ * @return player default eye height ++ */ ++ public float getDefaultEyeHeight() ++ { ++ return 0.12F; ++ } + } diff --git a/patches/minecraft/net/minecraft/entity/player/EntityPlayerMP.java.patch b/patches/minecraft/net/minecraft/entity/player/EntityPlayerMP.java.patch index 577132e0ab..1e197c8ace 100644 --- a/patches/minecraft/net/minecraft/entity/player/EntityPlayerMP.java.patch +++ b/patches/minecraft/net/minecraft/entity/player/EntityPlayerMP.java.patch @@ -33,7 +33,19 @@ this.mcServer = par1MinecraftServer; this.stepHeight = 0.0F; -@@ -289,7 +287,10 @@ +@@ -239,11 +237,6 @@ + this.yOffset = 0.0F; + } + +- public float getEyeHeight() +- { +- return 1.62F; +- } +- + /** + * Called to update the entity's position/logic. + */ +@@ -289,7 +282,10 @@ if (chunkcoordintpair != null && this.worldObj.blockExists(chunkcoordintpair.chunkXPos << 4, 0, chunkcoordintpair.chunkZPos << 4)) { arraylist.add(this.worldObj.getChunkFromChunkCoords(chunkcoordintpair.chunkXPos, chunkcoordintpair.chunkZPos)); @@ -45,7 +57,7 @@ } } -@@ -310,6 +311,7 @@ +@@ -310,6 +306,7 @@ { Chunk chunk = (Chunk)iterator2.next(); this.getServerForPlayer().getEntityTracker().func_85172_a(this, chunk); @@ -53,7 +65,7 @@ } } } -@@ -377,11 +379,25 @@ +@@ -377,11 +374,25 @@ */ public void onDeath(DamageSource par1DamageSource) { @@ -79,3 +91,20 @@ } Collection collection = this.worldObj.getScoreboard().func_96520_a(ScoreObjectiveCriteria.deathCount); +@@ -1043,4 +1054,16 @@ + { + return new ChunkCoordinates(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY + 0.5D), MathHelper.floor_double(this.posZ)); + } ++ ++ /* ===================================== FORGE START =====================================*/ ++ ++ /** ++ * Returns the default eye height of the player ++ * @return player default eye height ++ */ ++ @Override ++ public float getDefaultEyeHeight() ++ { ++ return 1.62F; ++ } + } From 32073a5bc1eadcc5b5fde07c7fdd003ed4838373 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 5 Sep 2013 07:45:29 -0400 Subject: [PATCH 13/19] Reduce patch size significantly --- .../entity/EntityOtherPlayerMP.java.patch | 51 +------------------ 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/patches/minecraft/net/minecraft/client/entity/EntityOtherPlayerMP.java.patch b/patches/minecraft/net/minecraft/client/entity/EntityOtherPlayerMP.java.patch index d7119a152f..4563e5cc29 100644 --- a/patches/minecraft/net/minecraft/client/entity/EntityOtherPlayerMP.java.patch +++ b/patches/minecraft/net/minecraft/client/entity/EntityOtherPlayerMP.java.patch @@ -1,61 +1,12 @@ --- ../src_base/minecraft/net/minecraft/client/entity/EntityOtherPlayerMP.java +++ ../src_work/minecraft/net/minecraft/client/entity/EntityOtherPlayerMP.java -@@ -170,29 +170,36 @@ +@@ -170,7 +170,8 @@ } } - public float getEyeHeight() -+ public void sendChatToPlayer(ChatMessageComponent par1ChatMessageComponent) -+ { -+ Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(par1ChatMessageComponent.toStringWithFormatting(true)); -+ } -+ -+ /** -+ * Returns true if the command sender is allowed to use the given command. -+ */ -+ public boolean canCommandSenderUseCommand(int par1, String par2Str) -+ { -+ return false; -+ } -+ -+ /** -+ * Return the position for this command sender. -+ */ -+ public ChunkCoordinates getPlayerCoordinates() -+ { -+ return new ChunkCoordinates(MathHelper.floor_double(this.posX + 0.5D), MathHelper.floor_double(this.posY + 0.5D), MathHelper.floor_double(this.posZ + 0.5D)); -+ } -+ -+ /* ===================================== FORGE START =====================================*/ -+ -+ /** -+ * Returns the default eye height of the player -+ * @return player default eye height -+ */ + @Override + public float getDefaultEyeHeight() { return 1.82F; } -- -- public void sendChatToPlayer(ChatMessageComponent par1ChatMessageComponent) -- { -- Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(par1ChatMessageComponent.toStringWithFormatting(true)); -- } -- -- /** -- * Returns true if the command sender is allowed to use the given command. -- */ -- public boolean canCommandSenderUseCommand(int par1, String par2Str) -- { -- return false; -- } -- -- /** -- * Return the position for this command sender. -- */ -- public ChunkCoordinates getPlayerCoordinates() -- { -- return new ChunkCoordinates(MathHelper.floor_double(this.posX + 0.5D), MathHelper.floor_double(this.posY + 0.5D), MathHelper.floor_double(this.posZ + 0.5D)); -- } - } From fe5f5e690e09a4a47d30ffe4a398937fca754618 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 5 Sep 2013 07:57:21 -0400 Subject: [PATCH 14/19] Fix patch for new MCP naming. --- .../net/minecraft/client/Minecraft.java.patch | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index e1420fbf6f..87cd03a947 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -62,16 +62,16 @@ { this.entityRenderer.itemRenderer.resetEquippedProgress2(); } -@@ -1575,7 +1585,7 @@ +@@ -1574,6 +1584,8 @@ + while (Mouse.next()) { - i = Mouse.getEventButton(); -- + if (ForgeHooksClient.postMouseEvent()) continue; - if (field_142025_a && i == 0 && (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157))) - { - i = 1; -@@ -2046,6 +2056,11 @@ ++ + i = Mouse.getEventButton(); + + if (isRunningOnMac && i == 0 && (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157))) +@@ -2046,6 +2058,11 @@ { this.statFileWriter.syncStats(); @@ -83,7 +83,7 @@ if (par1WorldClient == null) { NetClientHandler netclienthandler = this.getNetHandler(); -@@ -2063,6 +2078,18 @@ +@@ -2063,6 +2080,18 @@ if (this.theIntegratedServer != null) { this.theIntegratedServer.initiateShutdown(); @@ -102,7 +102,7 @@ } this.theIntegratedServer = null; -@@ -2236,107 +2263,12 @@ +@@ -2236,107 +2265,12 @@ if (this.objectMouseOver != null) { boolean flag = this.thePlayer.capabilities.isCreativeMode; @@ -214,7 +214,7 @@ if (flag) { -@@ -2419,11 +2351,18 @@ +@@ -2419,11 +2353,18 @@ par1PlayerUsageSnooper.addData("gl_max_texture_size", Integer.valueOf(getGLMaximumTextureSize())); } @@ -233,7 +233,7 @@ for (int i = 16384; i > 0; i >>= 1) { GL11.glTexImage2D(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_RGBA, i, i, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null); -@@ -2431,6 +2370,7 @@ +@@ -2431,6 +2372,7 @@ if (j != 0) { From 7549eb90a71383845aec9a9366244e565579fe91 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 5 Sep 2013 08:22:28 -0400 Subject: [PATCH 15/19] Add a bit of javadoc --- .../net/minecraft/entity/player/EntityPlayer.java.patch | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch index f535ef6990..168d0194ae 100644 --- a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch +++ b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch @@ -569,7 +569,7 @@ } public void setAbsorptionAmount(float par1) -@@ -2267,4 +2471,32 @@ +@@ -2267,4 +2471,39 @@ { FMLNetworkHandler.openGui(this, mod, modGuiId, world, x, y, z); } @@ -588,6 +588,10 @@ + return 0.12F; + } + ++ /** ++ * Get the currently computed display name, cached for efficiency. ++ * @return the current display name ++ */ + public String getDisplayName() + { + if(this.displayname == null) @@ -597,6 +601,9 @@ + return this.displayname; + } + ++ /** ++ * Force the displayed name to refresh ++ */ + public void refreshDisplayName() + { + this.displayname = ForgeEventFactory.getPlayerDisplayName(this, this.username); From 0443ef5a9e9a31259b17702b720fa8f03e627285 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 5 Sep 2013 09:14:10 -0400 Subject: [PATCH 16/19] MachineMuse, remember, there's TWO model formats supported! --- .../client/model/obj/WavefrontObject.java | 10 +++-- .../client/model/techne/TechneModel.java | 37 +++++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/client/net/minecraftforge/client/model/obj/WavefrontObject.java b/client/net/minecraftforge/client/model/obj/WavefrontObject.java index d39eba878b..20f9045104 100644 --- a/client/net/minecraftforge/client/model/obj/WavefrontObject.java +++ b/client/net/minecraftforge/client/model/obj/WavefrontObject.java @@ -169,6 +169,7 @@ public class WavefrontObject implements IModelCustom } } + @Override public void renderAll() { Tessellator tessellator = Tessellator.instance; @@ -194,6 +195,7 @@ public class WavefrontObject implements IModelCustom } } + @Override public void renderOnly(String... groupNames) { for (GroupObject groupObject : groupObjects) @@ -221,6 +223,7 @@ public class WavefrontObject implements IModelCustom } } + @Override public void renderPart(String partName) { for (GroupObject groupObject : groupObjects) @@ -244,18 +247,17 @@ public class WavefrontObject implements IModelCustom public void renderAllExcept(String... excludedGroupNames) { - boolean exclude; for (GroupObject groupObject : groupObjects) { - exclude=false; + boolean skipPart=false; for (String excludedGroupName : excludedGroupNames) { if (excludedGroupName.equalsIgnoreCase(groupObject.name)) { - exclude=true; + skipPart=true; } } - if(!exclude) + if(!skipPart) { groupObject.render(); } diff --git a/client/net/minecraftforge/client/model/techne/TechneModel.java b/client/net/minecraftforge/client/model/techne/TechneModel.java index 66a32aa9b3..d826ac65f3 100644 --- a/client/net/minecraftforge/client/model/techne/TechneModel.java +++ b/client/net/minecraftforge/client/model/techne/TechneModel.java @@ -37,6 +37,7 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraftforge.client.model.IModelCustom; import net.minecraftforge.client.model.ModelFormatException; +import net.minecraftforge.client.model.obj.GroupObject; /** * Techne model importer, based on iChun's Hats importer @@ -298,4 +299,40 @@ public class TechneModel extends ModelBase implements IModelCustom { part.renderWithRotation(1.0F); } } + + @Override + public void renderOnly(String... groupNames) + { + bindTexture(); + for (ModelRenderer part : parts.values()) + { + for (String groupName : groupNames) + { + if (groupName.equalsIgnoreCase(part.boxName)) + { + part.render(1.0f); + } + } + } + } + + @Override + public void renderAllExcept(String... excludedGroupNames) + { + for (ModelRenderer part : parts.values()) + { + boolean skipPart=false; + for (String excludedGroupName : excludedGroupNames) + { + if (excludedGroupName.equalsIgnoreCase(part.boxName)) + { + skipPart=true; + } + } + if(!skipPart) + { + part.render(1.0f); + } + } + } } From c84d99aa22dd96928dc1912c6ab7f54bfcef6c27 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 5 Sep 2013 10:08:02 -0400 Subject: [PATCH 17/19] Defer firing CreateDecorator until it's likely mods have had a chance to register their listener. Should close #759 --- .../common/BiomeDictionary.java | 22 +++++++-- .../common/ForgeDummyContainer.java | 7 +-- .../event/terraingen/BiomeEvent.java | 1 + .../terraingen/DeferredBiomeDecorator.java | 47 +++++++++++++++++++ .../world/biome/BiomeGenBase.java.patch | 6 +-- 5 files changed, 72 insertions(+), 11 deletions(-) create mode 100644 common/net/minecraftforge/event/terraingen/DeferredBiomeDecorator.java diff --git a/common/net/minecraftforge/common/BiomeDictionary.java b/common/net/minecraftforge/common/BiomeDictionary.java index d02a09cc14..ace31c7b2e 100644 --- a/common/net/minecraftforge/common/BiomeDictionary.java +++ b/common/net/minecraftforge/common/BiomeDictionary.java @@ -1,7 +1,10 @@ package net.minecraftforge.common; import java.util.*; + +import cpw.mods.fml.common.FMLLog; import net.minecraft.world.biome.*; +import net.minecraftforge.event.terraingen.DeferredBiomeDecorator; import static net.minecraft.world.biome.BiomeGenBase.*; import static net.minecraftforge.common.BiomeDictionary.Type.*; @@ -185,19 +188,30 @@ public class BiomeDictionary return biomeList[biomeID] != null; } + public static void registerAllBiomes() + { + FMLLog.warning("Redundant call to BiomeDictionary.registerAllBiomes ignored"); + } /** * Loops through the biome list and automatically adds tags to any biome that does not have any - * This should be called in postInit to make sure all biomes have been registered + * This is called by Forge at postinit time. It will additionally dispatch any deferred decorator + * creation events. * * DO NOT call this during world generation */ - public static void registerAllBiomes() + public static void registerAllBiomesAndGenerateEvents() { for(int i = 0; i < BIOME_LIST_SIZE; i++) { - if(BiomeGenBase.biomeList[i] != null) + BiomeGenBase biome = BiomeGenBase.biomeList[i]; + if (biome.theBiomeDecorator instanceof DeferredBiomeDecorator) { - checkRegistration(BiomeGenBase.biomeList[i]); + DeferredBiomeDecorator decorator = (DeferredBiomeDecorator) biome.theBiomeDecorator; + decorator.fireCreateEventAndReplace(); + } + if(biome != null) + { + checkRegistration(biome); } } } diff --git a/common/net/minecraftforge/common/ForgeDummyContainer.java b/common/net/minecraftforge/common/ForgeDummyContainer.java index 93deec9b55..a8c2b273a5 100644 --- a/common/net/minecraftforge/common/ForgeDummyContainer.java +++ b/common/net/minecraftforge/common/ForgeDummyContainer.java @@ -148,7 +148,7 @@ public class ForgeDummyContainer extends DummyModContainer implements WorldAcces @Override public boolean registerBus(EventBus bus, LoadController controller) { - bus.register(this); + bus.register(this); return true; } @@ -176,7 +176,8 @@ public class ForgeDummyContainer extends DummyModContainer implements WorldAcces @Subscribe public void postInit(FMLPostInitializationEvent evt) { - ForgeChunkManager.loadConfiguration(); + BiomeDictionary.registerAllBiomesAndGenerateEvents(); + ForgeChunkManager.loadConfiguration(); } @Subscribe @@ -201,7 +202,7 @@ public class ForgeDummyContainer extends DummyModContainer implements WorldAcces DimensionManager.loadDimensionDataMap(tag.hasKey("DimensionData") ? tag.getCompoundTag("DimensionData") : null); } } - + @Override public File getSource() { diff --git a/common/net/minecraftforge/event/terraingen/BiomeEvent.java b/common/net/minecraftforge/event/terraingen/BiomeEvent.java index 6bc3557a29..8f4917b9ee 100644 --- a/common/net/minecraftforge/event/terraingen/BiomeEvent.java +++ b/common/net/minecraftforge/event/terraingen/BiomeEvent.java @@ -1,5 +1,6 @@ package net.minecraftforge.event.terraingen; +import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.world.biome.BiomeDecorator; diff --git a/common/net/minecraftforge/event/terraingen/DeferredBiomeDecorator.java b/common/net/minecraftforge/event/terraingen/DeferredBiomeDecorator.java new file mode 100644 index 0000000000..219d3ca8a7 --- /dev/null +++ b/common/net/minecraftforge/event/terraingen/DeferredBiomeDecorator.java @@ -0,0 +1,47 @@ +package net.minecraftforge.event.terraingen; + +import java.util.Random; + +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeDecorator; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.MinecraftForge; + +public class DeferredBiomeDecorator extends BiomeDecorator { + private BiomeDecorator wrapped; + + public DeferredBiomeDecorator(BiomeGenBase biomeGenBase, BiomeDecorator wrappedOriginal) + { + super(biomeGenBase); + this.wrapped = wrappedOriginal; + } + + @Override + public void decorate(World par1World, Random par2Random, int par3, int par4) + { + fireCreateEventAndReplace(); + // On first call to decorate, we fire and substitute ourselves, if we haven't already done so + biome.theBiomeDecorator.decorate(par1World, par2Random, par3, par4); + } + public void fireCreateEventAndReplace() + { + // Copy any configuration from us to the real instance. + wrapped.bigMushroomsPerChunk = bigMushroomsPerChunk; + wrapped.cactiPerChunk = cactiPerChunk; + wrapped.clayPerChunk = clayPerChunk; + wrapped.deadBushPerChunk = deadBushPerChunk; + wrapped.flowersPerChunk = flowersPerChunk; + wrapped.generateLakes = generateLakes; + wrapped.grassPerChunk = grassPerChunk; + wrapped.mushroomsPerChunk = mushroomsPerChunk; + wrapped.reedsPerChunk = reedsPerChunk; + wrapped.sandPerChunk = sandPerChunk; + wrapped.sandPerChunk2 = sandPerChunk2; + wrapped.treesPerChunk = treesPerChunk; + wrapped.waterlilyPerChunk = waterlilyPerChunk; + + BiomeEvent.CreateDecorator event = new BiomeEvent.CreateDecorator(biome, wrapped); + MinecraftForge.TERRAIN_GEN_BUS.post(event); + biome.theBiomeDecorator = event.newBiomeDecorator; + } +} diff --git a/patches/minecraft/net/minecraft/world/biome/BiomeGenBase.java.patch b/patches/minecraft/net/minecraft/world/biome/BiomeGenBase.java.patch index bfb3641585..a94a319703 100644 --- a/patches/minecraft/net/minecraft/world/biome/BiomeGenBase.java.patch +++ b/patches/minecraft/net/minecraft/world/biome/BiomeGenBase.java.patch @@ -30,7 +30,7 @@ } @SideOnly(Side.CLIENT) -@@ -384,6 +387,38 @@ +@@ -384,6 +387,36 @@ { double d0 = (double)MathHelper.clamp_float(this.getFloatTemperature(), 0.0F, 1.0F); double d1 = (double)MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F); @@ -40,9 +40,7 @@ + + public BiomeDecorator getModdedBiomeDecorator(BiomeDecorator original) + { -+ BiomeEvent.CreateDecorator event = new BiomeEvent.CreateDecorator(this, original); -+ MinecraftForge.TERRAIN_GEN_BUS.post(event); -+ return event.newBiomeDecorator; ++ return new DeferredBiomeDecorator(this, original); + } + + @SideOnly(Side.CLIENT) From ca0e32cfd2fb8bba5b1e857039087a54f6969be2 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 5 Sep 2013 10:48:20 -0400 Subject: [PATCH 18/19] Add a harvestblock event, to allow mods to intercept and change the drops for blocks. Don't abuse this, or we'll have to take safety measures. Fires for both silktouch and non-silktouch harvesting, and provides the player. Note, you may need to change your break overrides to pass on the player for best results. --- .../event/world/BlockEvent.java | 46 ++++++++ .../net/minecraft/block/Block.java.patch | 110 +++++++++++++----- .../net/minecraft/block/BlockCocoa.java.patch | 23 ++-- .../net/minecraft/block/BlockCrops.java.patch | 22 ++-- .../block/BlockMobSpawner.java.patch | 22 ++++ .../net/minecraft/block/BlockOre.java.patch | 22 ++++ 6 files changed, 205 insertions(+), 40 deletions(-) create mode 100644 common/net/minecraftforge/event/world/BlockEvent.java create mode 100644 patches/minecraft/net/minecraft/block/BlockMobSpawner.java.patch create mode 100644 patches/minecraft/net/minecraft/block/BlockOre.java.patch diff --git a/common/net/minecraftforge/event/world/BlockEvent.java b/common/net/minecraftforge/event/world/BlockEvent.java new file mode 100644 index 0000000000..215e71e32c --- /dev/null +++ b/common/net/minecraftforge/event/world/BlockEvent.java @@ -0,0 +1,46 @@ +package net.minecraftforge.event.world; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.event.Event; + +public class BlockEvent extends Event { + public final int x; + public final int y; + public final int z; + public final World world; + public final Block block; + public final int blockMetadata; + public BlockEvent(int x, int y, int z, World world, Block block, int blockMetadata) + { + this.x = x; + this.y = y; + this.z = z; + this.world = world; + this.block = block; + this.blockMetadata = blockMetadata; + } + + public static class HarvestDropsEvent extends BlockEvent { + public final int fortuneLevel; + public final ArrayList drops; + public final boolean isSilkTouching; + public float dropChance; // Change to e.g. 1.0f, if you manipulate the list and want to guarantee it always drops + public final EntityPlayer harvester; // May be null for non-player harvesting such as explosions or machines + + public HarvestDropsEvent(int x, int y, int z, World world, Block block, int blockMetadata, int fortuneLevel, float dropChance, ArrayList drops, EntityPlayer harvester, boolean isSilkTouching) + { + super(x, y, z, world, block, blockMetadata); + this.fortuneLevel = fortuneLevel; + this.dropChance = dropChance; + this.drops = drops; + this.isSilkTouching = isSilkTouching; + this.harvester = harvester; + } + } + +} diff --git a/patches/minecraft/net/minecraft/block/Block.java.patch b/patches/minecraft/net/minecraft/block/Block.java.patch index a8c9df8a47..3b14f8b78f 100644 --- a/patches/minecraft/net/minecraft/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/block/Block.java.patch @@ -36,7 +36,7 @@ import net.minecraft.util.Icon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.StatCollector; -@@ -35,9 +44,19 @@ +@@ -35,9 +44,21 @@ import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -45,7 +45,9 @@ +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.IPlantable; ++import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.RotationHelper; ++import net.minecraftforge.event.world.BlockEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; @@ -56,7 +58,7 @@ /** * used as foreach item, if item.tab = current tab, display it on the screen */ -@@ -460,9 +479,10 @@ +@@ -460,9 +481,10 @@ return this.needsRandomTick; } @@ -68,7 +70,7 @@ } /** -@@ -485,7 +505,7 @@ +@@ -485,7 +507,7 @@ */ public float getBlockBrightness(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { @@ -77,7 +79,7 @@ } @SideOnly(Side.CLIENT) -@@ -495,7 +515,7 @@ +@@ -495,7 +517,7 @@ */ public int getMixedBrightnessForBlock(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { @@ -86,7 +88,7 @@ } @SideOnly(Side.CLIENT) -@@ -648,7 +668,13 @@ +@@ -648,7 +670,13 @@ * different metadata value, but before the new metadata value is set. Args: World, x, y, z, old block ID, old * metadata */ @@ -101,7 +103,7 @@ /** * Returns the quantity of items to drop on block destruction. -@@ -673,7 +699,7 @@ +@@ -673,7 +701,7 @@ public float getPlayerRelativeBlockHardness(EntityPlayer par1EntityPlayer, World par2World, int par3, int par4, int par5) { float f = this.getBlockHardness(par2World, par3, par4, par5); @@ -110,30 +112,41 @@ } /** -@@ -691,18 +717,13 @@ +@@ -681,7 +709,7 @@ + */ + public final void dropBlockAsItem(World par1World, int par2, int par3, int par4, int par5, int par6) { - if (!par1World.isRemote) - { +- this.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, 1.0F, par6); ++ dropBlockAsItem(par1World, par2, par3, par4, par5, par6, null); + } + + /** +@@ -689,23 +717,7 @@ + */ + public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7) + { +- if (!par1World.isRemote) +- { - int j1 = this.quantityDroppedWithBonus(par7, par1World.rand); - - for (int k1 = 0; k1 < j1; ++k1) -+ ArrayList items = getBlockDropped(par1World, par2, par3, par4, par5, par7); -+ -+ for (ItemStack item : items) - { - if (par1World.rand.nextFloat() <= par6) - { +- { +- if (par1World.rand.nextFloat() <= par6) +- { - int l1 = this.idDropped(par5, par1World.rand, par7); - - if (l1 > 0) - { - this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(l1, 1, this.damageDropped(par5))); - } -+ this.dropBlockAsItem_do(par1World, par2, par3, par4, item); - } - } - } -@@ -935,7 +956,8 @@ +- } +- } +- } ++ dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, par7, null); + } + + /** +@@ -935,7 +947,8 @@ public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) { int l = par1World.getBlockId(par2, par3, par4); @@ -143,7 +156,7 @@ } /** -@@ -1095,7 +1117,7 @@ +@@ -1095,28 +1108,38 @@ par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1); par2EntityPlayer.addExhaustion(0.025F); @@ -151,11 +164,35 @@ + if (this.canSilkHarvest(par1World, par2EntityPlayer, par3, par4, par5, par6) && EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer)) { ItemStack itemstack = this.createStackedBlock(par6); - -@@ -1111,12 +1133,13 @@ +- +- if (itemstack != null) ++ ArrayList results = new ArrayList(); ++ if (itemstack!=null) + { +- this.dropBlockAsItem_do(par1World, par3, par4, par5, itemstack); ++ results.add(itemstack); + } ++ ++ MinecraftForge.EVENT_BUS.post(new BlockEvent.HarvestDropsEvent(par3, par4, par5, par1World, this, par6, 0, 1.0f, results, par2EntityPlayer, true)); ++ if (itemstack != null && !results.isEmpty()) ++ { ++ for (ItemStack is : results) ++ { ++ this.dropBlockAsItem_do(par1World, par3, par4, par5, is); ++ } ++ } } - } - + else + { + int i1 = EnchantmentHelper.getFortuneModifier(par2EntityPlayer); +- this.dropBlockAsItem(par1World, par3, par4, par5, par6, i1); +- } +- } +- ++ this.dropBlockAsItem(par1World, par3, par4, par5, par6, i1, par2EntityPlayer); ++ } ++ } ++ + private int silk_check_meta = -1; //Dirty hack to stop us from needing to special case the silk check hook. /** * Return true if a player with Silk Touch can harvest this block directly, and not its normal drops. @@ -167,7 +204,7 @@ } /** -@@ -1457,4 +1480,979 @@ +@@ -1457,4 +1480,1000 @@ canBlockGrass[0] = true; StatList.initBreakableStats(); } @@ -536,6 +573,27 @@ + return ret; + } + ++ public final void dropBlockAsItem(World par1World, int par2, int par3, int par4, int par5, int par6, EntityPlayer player) ++ { ++ this.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, 1.0F, par6, player); ++ } ++ ++ public void dropBlockAsItemWithChance(World world, int x, int y, int z, int metadata, float dropChance, int fortune, EntityPlayer player) ++ { ++ if (!world.isRemote) ++ { ++ ArrayList items = getBlockDropped(world, x, y, z, metadata, fortune); ++ MinecraftForge.EVENT_BUS.post(new BlockEvent.HarvestDropsEvent(x, y, z, world, this, metadata, fortune, dropChance, items, player, false)); ++ for (ItemStack item : items) ++ { ++ if (world.rand.nextFloat() <= dropChance) ++ { ++ this.dropBlockAsItem_do(world, x, y, z, item); ++ } ++ } ++ } ++ } ++ + /** + * Determines if a specified mob type can spawn on this block, returning false will + * prevent any mob from spawning on the block. diff --git a/patches/minecraft/net/minecraft/block/BlockCocoa.java.patch b/patches/minecraft/net/minecraft/block/BlockCocoa.java.patch index 5fd3e3401d..6580ca541a 100644 --- a/patches/minecraft/net/minecraft/block/BlockCocoa.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockCocoa.java.patch @@ -1,6 +1,6 @@ --- ../src_base/minecraft/net/minecraft/block/BlockCocoa.java +++ ../src_work/minecraft/net/minecraft/block/BlockCocoa.java -@@ -2,6 +2,8 @@ +@@ -2,10 +2,13 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -9,12 +9,21 @@ import java.util.Random; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; -@@ -201,7 +203,14 @@ + import net.minecraft.entity.EntityLivingBase; ++import net.minecraft.entity.player.EntityPlayer; + import net.minecraft.item.Item; + import net.minecraft.item.ItemStack; + import net.minecraft.util.AxisAlignedBB; +@@ -199,9 +202,16 @@ + /** + * Drops the block items with a specified chance of dropping the specified items */ - public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7) - { +- public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7) +- { - int j1 = func_72219_c(par5); -+ super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, 0); ++ public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7, EntityPlayer player) ++ { ++ super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, 0, player); + } + + @Override @@ -25,7 +34,7 @@ byte b0 = 1; if (j1 >= 2) -@@ -211,8 +220,9 @@ +@@ -211,8 +221,9 @@ for (int k1 = 0; k1 < b0; ++k1) { @@ -37,7 +46,7 @@ } @SideOnly(Side.CLIENT) -@@ -248,4 +258,10 @@ +@@ -248,4 +259,10 @@ this.iconArray[i] = par1IconRegister.registerIcon(this.getTextureName() + "_stage_" + i); } } diff --git a/patches/minecraft/net/minecraft/block/BlockCrops.java.patch b/patches/minecraft/net/minecraft/block/BlockCrops.java.patch index 66a57d1606..c72ff3ff6f 100644 --- a/patches/minecraft/net/minecraft/block/BlockCrops.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockCrops.java.patch @@ -1,6 +1,6 @@ --- ../src_base/minecraft/net/minecraft/block/BlockCrops.java +++ ../src_work/minecraft/net/minecraft/block/BlockCrops.java -@@ -2,6 +2,7 @@ +@@ -2,14 +2,17 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -8,7 +8,9 @@ import java.util.Random; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; -@@ -10,6 +11,7 @@ ++import net.minecraft.entity.player.EntityPlayer; + import net.minecraft.item.Item; + import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; @@ -16,7 +18,7 @@ public class BlockCrops extends BlockFlower { -@@ -103,11 +105,11 @@ +@@ -103,11 +106,11 @@ int j3 = par1World.getBlockId(l2, par3 - 1, i3); float f1 = 0.0F; @@ -30,14 +32,20 @@ { f1 = 3.0F; } -@@ -175,22 +177,25 @@ - public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7) - { - super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, 0); +@@ -172,25 +175,28 @@ + /** + * Drops the block items with a specified chance of dropping the specified items + */ +- public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7) +- { +- super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, 0); - - if (!par1World.isRemote) - { - if (par5 >= 7) ++ public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7, EntityPlayer player) ++ { ++ super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, 0, player); + } + + @Override diff --git a/patches/minecraft/net/minecraft/block/BlockMobSpawner.java.patch b/patches/minecraft/net/minecraft/block/BlockMobSpawner.java.patch new file mode 100644 index 0000000000..6280e811a6 --- /dev/null +++ b/patches/minecraft/net/minecraft/block/BlockMobSpawner.java.patch @@ -0,0 +1,22 @@ +--- ../src_base/minecraft/net/minecraft/block/BlockMobSpawner.java ++++ ../src_work/minecraft/net/minecraft/block/BlockMobSpawner.java +@@ -4,6 +4,7 @@ + import cpw.mods.fml.relauncher.SideOnly; + import java.util.Random; + import net.minecraft.block.material.Material; ++import net.minecraft.entity.player.EntityPlayer; + import net.minecraft.tileentity.TileEntity; + import net.minecraft.tileentity.TileEntityMobSpawner; + import net.minecraft.world.World; +@@ -42,9 +43,9 @@ + /** + * Drops the block items with a specified chance of dropping the specified items + */ +- public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7) ++ public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7, EntityPlayer player) + { +- super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, par7); ++ super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, par7, player); + int j1 = 15 + par1World.rand.nextInt(15) + par1World.rand.nextInt(15); + this.dropXpOnBlockBreak(par1World, par2, par3, par4, j1); + } diff --git a/patches/minecraft/net/minecraft/block/BlockOre.java.patch b/patches/minecraft/net/minecraft/block/BlockOre.java.patch new file mode 100644 index 0000000000..14e092029c --- /dev/null +++ b/patches/minecraft/net/minecraft/block/BlockOre.java.patch @@ -0,0 +1,22 @@ +--- ../src_base/minecraft/net/minecraft/block/BlockOre.java ++++ ../src_work/minecraft/net/minecraft/block/BlockOre.java +@@ -3,6 +3,7 @@ + import java.util.Random; + import net.minecraft.block.material.Material; + import net.minecraft.creativetab.CreativeTabs; ++import net.minecraft.entity.player.EntityPlayer; + import net.minecraft.item.Item; + import net.minecraft.util.MathHelper; + import net.minecraft.world.World; +@@ -56,9 +57,9 @@ + /** + * Drops the block items with a specified chance of dropping the specified items + */ +- public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7) ++ public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7, EntityPlayer player) + { +- super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, par7); ++ super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, par7, player); + + if (this.idDropped(par5, par1World.rand, par7) != this.blockID) + { From 99c6662f9d6405ad239f48db187cc1a923aab16f Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 5 Sep 2013 12:08:16 -0400 Subject: [PATCH 19/19] Add in a block reverse lookup for fluids. Closes #749 --- .../minecraftforge/fluids/FluidRegistry.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/common/net/minecraftforge/fluids/FluidRegistry.java b/common/net/minecraftforge/fluids/FluidRegistry.java index b55d215051..df4eaa174f 100644 --- a/common/net/minecraftforge/fluids/FluidRegistry.java +++ b/common/net/minecraftforge/fluids/FluidRegistry.java @@ -24,7 +24,8 @@ public abstract class FluidRegistry static HashMap fluids = new HashMap(); static BiMap fluidIDs = HashBiMap.create(); - + static BiMap fluidBlocks; + public static final Fluid WATER = new Fluid("water").setBlockID(Block.waterStill.blockID).setUnlocalizedName(Block.waterStill.getUnlocalizedName()); public static final Fluid LAVA = new Fluid("lava").setBlockID(Block.lavaStill.blockID).setLuminosity(15).setDensity(3000).setViscosity(6000).setTemperature(1300).setUnlocalizedName(Block.lavaStill.getUnlocalizedName()); @@ -128,6 +129,21 @@ public abstract class FluidRegistry return ImmutableMap.copyOf(fluidIDs); } + public static Fluid lookupFluidForBlock(Block block) + { + if (fluidBlocks == null) + { + for (Fluid fluid : fluids.values()) + { + if (fluid.canBePlacedInWorld() && Block.blocksList[fluid.getBlockID()] != null) + { + fluidBlocks.put(Block.blocksList[fluid.getBlockID()], fluid); + } + } + } + return fluidBlocks.get(block); + } + public static class FluidRegisterEvent extends Event { public final String fluidName;