From fa41058ba1e87f0ea22dfbc15b71a0355a0272eb Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 4 Oct 2013 17:21:14 -0400 Subject: [PATCH 1/5] Updated FML: MinecraftForge/FML@63ba3aa0099f43183315fb4e16f9e8e8007362f8 Add in support for Optional interfaces and methods. Be gone coremods! --- fml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fml b/fml index 5265e34a3..63ba3aa00 160000 --- a/fml +++ b/fml @@ -1 +1 @@ -Subproject commit 5265e34a350adbb762264379f0134bfa40d33eaa +Subproject commit 63ba3aa0099f43183315fb4e16f9e8e8007362f8 From 8d0b58ee6fe1dca88f5874a9dd08368b0f5859e6 Mon Sep 17 00:00:00 2001 From: Eurymachus Date: Sat, 5 Oct 2013 12:10:00 +0100 Subject: [PATCH 2/5] Added PlayerOpenContainerEvent and added ForgeHooks.canInteractWith - Used to override the canInteractWith during player tick - setResult to ALLOW/DENY as required - Defaults to Vanilla behaviour in any other instance. Required for LittleBlocks Mod and to Assist Gullivers Mod --- .../net/minecraftforge/common/ForgeHooks.java | 10 +++++++ .../player/PlayerOpenContainerEvent.java | 29 +++++++++++++++++++ .../entity/player/EntityPlayer.java.patch | 9 ++++++ .../entity/player/EntityPlayerMP.java.patch | 9 ++++++ 4 files changed, 57 insertions(+) create mode 100644 common/net/minecraftforge/event/entity/player/PlayerOpenContainerEvent.java diff --git a/common/net/minecraftforge/common/ForgeHooks.java b/common/net/minecraftforge/common/ForgeHooks.java index 7916f10ba..a8c6555b4 100644 --- a/common/net/minecraftforge/common/ForgeHooks.java +++ b/common/net/minecraftforge/common/ForgeHooks.java @@ -11,6 +11,7 @@ import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemAxe; @@ -27,6 +28,7 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.WeightedRandom; import net.minecraft.util.WeightedRandomItem; import net.minecraft.world.World; +import net.minecraftforge.event.Event; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.ServerChatEvent; import net.minecraftforge.event.entity.item.ItemTossEvent; @@ -38,6 +40,7 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; +import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent; public class ForgeHooks { @@ -430,4 +433,11 @@ public class ForgeHooks } return event.component; } + + public static boolean canInteractWith(EntityPlayer player, Container openContainer) + { + PlayerOpenContainerEvent event = new PlayerOpenContainerEvent(player, openContainer); + MinecraftForge.EVENT_BUS.post(event); + return event.getResult() == Event.Result.DEFAULT ? event.canInteractWith : event.getResult() == Event.Result.ALLOW ? true : false; + } } diff --git a/common/net/minecraftforge/event/entity/player/PlayerOpenContainerEvent.java b/common/net/minecraftforge/event/entity/player/PlayerOpenContainerEvent.java new file mode 100644 index 000000000..6ea781c1c --- /dev/null +++ b/common/net/minecraftforge/event/entity/player/PlayerOpenContainerEvent.java @@ -0,0 +1,29 @@ +package net.minecraftforge.event.entity.player; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraftforge.event.Event.HasResult; + +@HasResult +public class PlayerOpenContainerEvent extends PlayerEvent +{ + + public final boolean canInteractWith; + + /** + * This event is fired when a player attempts to view a container during + * player tick. + * + * setResult ALLOW to allow the container to stay open + * setResult DENY to force close the container (denying access) + * + * DEFAULT is vanilla behaviour + * + */ + + public PlayerOpenContainerEvent(EntityPlayer player, Container openContainer) + { + super(player); + this.canInteractWith = openContainer.canInteractWith(player); + } +} diff --git a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch index 3ef593709..f1b2fccd4 100644 --- a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch +++ b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch @@ -64,6 +64,15 @@ if (this.itemInUseCount <= 25 && this.itemInUseCount % 4 == 0) { this.updateItemUse(itemstack, 5); +@@ -321,7 +341,7 @@ + + super.onUpdate(); + +- if (!this.worldObj.isRemote && this.openContainer != null && !this.openContainer.canInteractWith(this)) ++ if (!this.worldObj.isRemote && this.openContainer != null && !ForgeHooks.canInteractWith(this, this.openContainer)) + { + this.closeScreen(); + this.openContainer = this.inventoryContainer; @@ -429,7 +449,7 @@ vec31.rotateAroundX(-this.rotationPitch * (float)Math.PI / 180.0F); vec31.rotateAroundY(-this.rotationYaw * (float)Math.PI / 180.0F); diff --git a/patches/minecraft/net/minecraft/entity/player/EntityPlayerMP.java.patch b/patches/minecraft/net/minecraft/entity/player/EntityPlayerMP.java.patch index d81404fd4..6d2c8e179 100644 --- a/patches/minecraft/net/minecraft/entity/player/EntityPlayerMP.java.patch +++ b/patches/minecraft/net/minecraft/entity/player/EntityPlayerMP.java.patch @@ -45,6 +45,15 @@ /** * Called to update the entity's position/logic. */ +@@ -254,7 +247,7 @@ + --this.initialInvulnerability; + this.openContainer.detectAndSendChanges(); + +- if (!this.worldObj.isRemote && !this.openContainer.canInteractWith(this)) ++ if (!this.worldObj.isRemote && !ForgeHooks.canInteractWith(this, this.openContainer)) + { + this.closeScreen(); + this.openContainer = this.inventoryContainer; @@ -290,7 +283,10 @@ if (chunkcoordintpair != null && this.worldObj.blockExists(chunkcoordintpair.chunkXPos << 4, 0, chunkcoordintpair.chunkZPos << 4)) { From 0866d88126fc2a5c0efc17deac10e2372422a420 Mon Sep 17 00:00:00 2001 From: Christian Date: Sun, 6 Oct 2013 11:17:58 -0400 Subject: [PATCH 3/5] Updated FML: MinecraftForge/FML@bc64ceabef76b1f4667b22ca8241b72351b44338 Optional shouldn't be constructable itself. It's purely a wrapper thing. MinecraftForge/FML@55525f6d2eb24f42c26a291b8ce98feb4d4498c9 ModLoader is officially deprecated. It will all cease to be with 1.7. --- fml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fml b/fml index 63ba3aa00..55525f6d2 160000 --- a/fml +++ b/fml @@ -1 +1 @@ -Subproject commit 63ba3aa0099f43183315fb4e16f9e8e8007362f8 +Subproject commit 55525f6d2eb24f42c26a291b8ce98feb4d4498c9 From c8df5b832e5bafcbb93d05091366a5fa7b33a8ec Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Sun, 6 Oct 2013 11:20:09 -0700 Subject: [PATCH 4/5] MinecraftForge/FML@a381874bb9c3bdeeb508bb81719b4d210eb29696 Delay sound system backend initalization to speed up startup and prevent race condition on some computers. --- fml | 2 +- .../net/minecraft/client/Minecraft.java.patch | 26 +++++++++---------- .../client/audio/SoundManager.java.patch | 20 +++++++------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/fml b/fml index 55525f6d2..a381874bb 160000 --- a/fml +++ b/fml @@ -1 +1 @@ -Subproject commit 55525f6d2eb24f42c26a291b8ce98feb4d4498c9 +Subproject commit a381874bb9c3bdeeb508bb81719b4d210eb29696 diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 5e3cec260..40ad4ecca 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -26,7 +26,7 @@ } catch (LWJGLException lwjglexception) { -@@ -497,7 +507,7 @@ +@@ -498,7 +508,7 @@ this.effectRenderer = new EffectRenderer(this.theWorld, this.renderEngine); FMLClientHandler.instance().finishMinecraftLoading(); this.checkGLError("Post startup"); @@ -35,7 +35,7 @@ if (this.serverName != null) { -@@ -679,11 +689,6 @@ +@@ -680,11 +690,6 @@ */ public void displayGuiScreen(GuiScreen par1GuiScreen) { @@ -47,7 +47,7 @@ this.statFileWriter.syncStats(); if (par1GuiScreen == null && this.theWorld == null) -@@ -693,6 +698,20 @@ +@@ -694,6 +699,20 @@ else if (par1GuiScreen == null && this.thePlayer.getHealth() <= 0.0F) { par1GuiScreen = new GuiGameOver(); @@ -68,7 +68,7 @@ } if (par1GuiScreen instanceof GuiMainMenu) -@@ -1300,7 +1319,7 @@ +@@ -1301,7 +1320,7 @@ if (this.thePlayer.isCurrentToolAdventureModeExempt(j, k, l)) { @@ -77,7 +77,7 @@ this.thePlayer.swingItem(); } } -@@ -1366,7 +1385,8 @@ +@@ -1367,7 +1386,8 @@ { int j1 = itemstack != null ? itemstack.stackSize : 0; @@ -87,7 +87,7 @@ { flag = false; this.thePlayer.swingItem(); -@@ -1392,7 +1412,8 @@ +@@ -1393,7 +1413,8 @@ { ItemStack itemstack1 = this.thePlayer.inventory.getCurrentItem(); @@ -97,7 +97,7 @@ { this.entityRenderer.itemRenderer.resetEquippedProgress2(); } -@@ -1574,6 +1595,8 @@ +@@ -1575,6 +1596,8 @@ while (Mouse.next()) { @@ -106,7 +106,7 @@ i = Mouse.getEventButton(); if (isRunningOnMac && i == 0 && (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157))) -@@ -2046,6 +2069,11 @@ +@@ -2047,6 +2070,11 @@ { this.statFileWriter.syncStats(); @@ -118,7 +118,7 @@ if (par1WorldClient == null) { NetClientHandler netclienthandler = this.getNetHandler(); -@@ -2063,6 +2091,18 @@ +@@ -2064,6 +2092,18 @@ if (this.theIntegratedServer != null) { this.theIntegratedServer.initiateShutdown(); @@ -137,7 +137,7 @@ } this.theIntegratedServer = null; -@@ -2225,7 +2265,7 @@ +@@ -2226,7 +2266,7 @@ */ public boolean handleClientCommand(String par1Str) { @@ -146,7 +146,7 @@ } /** -@@ -2236,107 +2276,12 @@ +@@ -2237,107 +2277,12 @@ if (this.objectMouseOver != null) { boolean flag = this.thePlayer.capabilities.isCreativeMode; @@ -258,7 +258,7 @@ if (flag) { -@@ -2419,11 +2364,18 @@ +@@ -2420,11 +2365,18 @@ par1PlayerUsageSnooper.addData("gl_max_texture_size", Integer.valueOf(getGLMaximumTextureSize())); } @@ -277,7 +277,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 +2383,7 @@ +@@ -2432,6 +2384,7 @@ if (j != 0) { diff --git a/patches/minecraft/net/minecraft/client/audio/SoundManager.java.patch b/patches/minecraft/net/minecraft/client/audio/SoundManager.java.patch index 8e67548d8..b9b624184 100644 --- a/patches/minecraft/net/minecraft/client/audio/SoundManager.java.patch +++ b/patches/minecraft/net/minecraft/client/audio/SoundManager.java.patch @@ -10,7 +10,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.io.File; -@@ -61,9 +65,11 @@ +@@ -62,9 +66,11 @@ private Random rand = new Random(); private int ticksBeforeMusic; @@ -23,7 +23,7 @@ this.options = par2GameSettings; this.fileAssets = par3File; this.soundPoolSounds = new SoundPool(par1ResourceManager, "sound", true); -@@ -75,6 +81,7 @@ +@@ -76,6 +82,7 @@ SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class); SoundSystemConfig.setCodec("ogg", CodecJOrbis.class); SoundSystemConfig.setCodec("wav", CodecWav.class); @@ -31,7 +31,7 @@ } catch (SoundSystemException soundsystemexception) { -@@ -90,6 +97,7 @@ +@@ -92,6 +99,7 @@ this.stopAllSounds(); this.cleanup(); this.tryToSetLibraryAndCodecs(); @@ -39,7 +39,7 @@ } private void loadSounds() -@@ -236,10 +244,11 @@ +@@ -238,10 +246,11 @@ else { SoundPoolEntry soundpoolentry = this.soundPoolMusic.getRandomSound(); @@ -52,7 +52,7 @@ this.sndSystem.backgroundMusic("BgMusic", soundpoolentry.getSoundUrl(), soundpoolentry.getSoundName(), false); this.sndSystem.setVolume("BgMusic", this.options.musicVolume); this.sndSystem.play("BgMusic"); -@@ -307,6 +316,7 @@ +@@ -309,6 +318,7 @@ if (par1Str != null) { SoundPoolEntry soundpoolentry = this.soundPoolStreaming.getRandomSoundFromSoundPool(par1Str); @@ -60,7 +60,7 @@ if (soundpoolentry != null) { -@@ -317,6 +327,7 @@ +@@ -319,6 +329,7 @@ this.sndSystem.newStreamingSource(true, s1, soundpoolentry.getSoundUrl(), soundpoolentry.getSoundName(), false, par2, par3, par4, 2, 64.0F); this.sndSystem.setVolume(s1, 0.5F * this.options.soundVolume); @@ -68,7 +68,7 @@ this.sndSystem.play(s1); } } -@@ -485,6 +496,7 @@ +@@ -487,6 +498,7 @@ if (this.loaded && this.options.soundVolume != 0.0F) { SoundPoolEntry soundpoolentry = this.soundPoolSounds.getRandomSoundFromSoundPool(par1Str); @@ -76,7 +76,7 @@ if (soundpoolentry != null && par5 > 0.0F) { -@@ -506,6 +518,7 @@ +@@ -508,6 +520,7 @@ this.sndSystem.setPitch(s1, par6); this.sndSystem.setVolume(s1, par5 * this.options.soundVolume); @@ -84,7 +84,7 @@ this.sndSystem.play(s1); } } -@@ -520,6 +533,7 @@ +@@ -522,6 +535,7 @@ if (this.loaded && this.options.soundVolume != 0.0F) { SoundPoolEntry soundpoolentry = this.soundPoolSounds.getRandomSoundFromSoundPool(par1Str); @@ -92,7 +92,7 @@ if (soundpoolentry != null && par2 > 0.0F) { -@@ -535,6 +549,7 @@ +@@ -537,6 +551,7 @@ par2 *= 0.25F; this.sndSystem.setPitch(s1, par3); this.sndSystem.setVolume(s1, par2 * this.options.soundVolume); From 1a6743331b5d7b75de3681c3d8a37278ec6c0f2f Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Mon, 7 Oct 2013 14:16:04 -0700 Subject: [PATCH 5/5] Fix repeated argument in CleintCommands. --- client/net/minecraftforge/client/ClientCommandHandler.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/net/minecraftforge/client/ClientCommandHandler.java b/client/net/minecraftforge/client/ClientCommandHandler.java index b929e723e..b6d9c44a5 100644 --- a/client/net/minecraftforge/client/ClientCommandHandler.java +++ b/client/net/minecraftforge/client/ClientCommandHandler.java @@ -43,9 +43,10 @@ public class ClientCommandHandler extends CommandHandler message = message.substring(1); } - String[] args = message.split(" "); - String commandName = args[0]; - System.arraycopy(args, 1, args, 0, args.length - 1); + String[] temp = message.split(" "); + String[] args = new String[temp.length - 1]; + String commandName = temp[0]; + System.arraycopy(temp, 1, args, 0, args.length); ICommand icommand = (ICommand) getCommands().get(commandName); try