Merge branch 'upstream/master'

This commit is contained in:
OniBait 2013-10-08 19:04:54 -05:00
commit 303288e8b1
8 changed files with 83 additions and 27 deletions

View file

@ -43,9 +43,10 @@ public class ClientCommandHandler extends CommandHandler
message = message.substring(1); message = message.substring(1);
} }
String[] args = message.split(" "); String[] temp = message.split(" ");
String commandName = args[0]; String[] args = new String[temp.length - 1];
System.arraycopy(args, 1, args, 0, args.length - 1); String commandName = temp[0];
System.arraycopy(temp, 1, args, 0, args.length);
ICommand icommand = (ICommand) getCommands().get(commandName); ICommand icommand = (ICommand) getCommands().get(commandName);
try try

View file

@ -46,6 +46,7 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent;
import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.BlockEvent;
public class ForgeHooks public class ForgeHooks
@ -440,6 +441,13 @@ public class ForgeHooks
return event.component; 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;
}
public static BlockEvent.BreakEvent onBlockBreakEvent(World world, EnumGameType gameType, EntityPlayerMP entityPlayer, int x, int y, int z) public static BlockEvent.BreakEvent onBlockBreakEvent(World world, EnumGameType gameType, EntityPlayerMP entityPlayer, int x, int y, int z)
{ {
// Logic from tryHarvestBlock for pre-canceling the event // Logic from tryHarvestBlock for pre-canceling the event

View file

@ -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);
}
}

2
fml

@ -1 +1 @@
Subproject commit 5265e34a350adbb762264379f0134bfa40d33eaa Subproject commit a381874bb9c3bdeeb508bb81719b4d210eb29696

View file

@ -26,7 +26,7 @@
} }
catch (LWJGLException lwjglexception) catch (LWJGLException lwjglexception)
{ {
@@ -497,7 +507,7 @@ @@ -498,7 +508,7 @@
this.effectRenderer = new EffectRenderer(this.theWorld, this.renderEngine); this.effectRenderer = new EffectRenderer(this.theWorld, this.renderEngine);
FMLClientHandler.instance().finishMinecraftLoading(); FMLClientHandler.instance().finishMinecraftLoading();
this.checkGLError("Post startup"); this.checkGLError("Post startup");
@ -35,7 +35,7 @@
if (this.serverName != null) if (this.serverName != null)
{ {
@@ -679,11 +689,6 @@ @@ -680,11 +690,6 @@
*/ */
public void displayGuiScreen(GuiScreen par1GuiScreen) public void displayGuiScreen(GuiScreen par1GuiScreen)
{ {
@ -47,7 +47,7 @@
this.statFileWriter.syncStats(); this.statFileWriter.syncStats();
if (par1GuiScreen == null && this.theWorld == null) if (par1GuiScreen == null && this.theWorld == null)
@@ -693,6 +698,20 @@ @@ -694,6 +699,20 @@
else if (par1GuiScreen == null && this.thePlayer.getHealth() <= 0.0F) else if (par1GuiScreen == null && this.thePlayer.getHealth() <= 0.0F)
{ {
par1GuiScreen = new GuiGameOver(); par1GuiScreen = new GuiGameOver();
@ -68,7 +68,7 @@
} }
if (par1GuiScreen instanceof GuiMainMenu) if (par1GuiScreen instanceof GuiMainMenu)
@@ -1300,7 +1319,7 @@ @@ -1301,7 +1320,7 @@
if (this.thePlayer.isCurrentToolAdventureModeExempt(j, k, l)) if (this.thePlayer.isCurrentToolAdventureModeExempt(j, k, l))
{ {
@ -77,7 +77,7 @@
this.thePlayer.swingItem(); this.thePlayer.swingItem();
} }
} }
@@ -1366,7 +1385,8 @@ @@ -1367,7 +1386,8 @@
{ {
int j1 = itemstack != null ? itemstack.stackSize : 0; int j1 = itemstack != null ? itemstack.stackSize : 0;
@ -87,7 +87,7 @@
{ {
flag = false; flag = false;
this.thePlayer.swingItem(); this.thePlayer.swingItem();
@@ -1392,7 +1412,8 @@ @@ -1393,7 +1413,8 @@
{ {
ItemStack itemstack1 = this.thePlayer.inventory.getCurrentItem(); ItemStack itemstack1 = this.thePlayer.inventory.getCurrentItem();
@ -97,7 +97,7 @@
{ {
this.entityRenderer.itemRenderer.resetEquippedProgress2(); this.entityRenderer.itemRenderer.resetEquippedProgress2();
} }
@@ -1574,6 +1595,8 @@ @@ -1575,6 +1596,8 @@
while (Mouse.next()) while (Mouse.next())
{ {
@ -106,7 +106,7 @@
i = Mouse.getEventButton(); i = Mouse.getEventButton();
if (isRunningOnMac && i == 0 && (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157))) if (isRunningOnMac && i == 0 && (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)))
@@ -2046,6 +2069,11 @@ @@ -2047,6 +2070,11 @@
{ {
this.statFileWriter.syncStats(); this.statFileWriter.syncStats();
@ -118,7 +118,7 @@
if (par1WorldClient == null) if (par1WorldClient == null)
{ {
NetClientHandler netclienthandler = this.getNetHandler(); NetClientHandler netclienthandler = this.getNetHandler();
@@ -2063,6 +2091,18 @@ @@ -2064,6 +2092,18 @@
if (this.theIntegratedServer != null) if (this.theIntegratedServer != null)
{ {
this.theIntegratedServer.initiateShutdown(); this.theIntegratedServer.initiateShutdown();
@ -137,7 +137,7 @@
} }
this.theIntegratedServer = null; this.theIntegratedServer = null;
@@ -2225,7 +2265,7 @@ @@ -2226,7 +2266,7 @@
*/ */
public boolean handleClientCommand(String par1Str) public boolean handleClientCommand(String par1Str)
{ {
@ -146,7 +146,7 @@
} }
/** /**
@@ -2236,107 +2276,12 @@ @@ -2237,107 +2277,12 @@
if (this.objectMouseOver != null) if (this.objectMouseOver != null)
{ {
boolean flag = this.thePlayer.capabilities.isCreativeMode; boolean flag = this.thePlayer.capabilities.isCreativeMode;
@ -258,7 +258,7 @@
if (flag) if (flag)
{ {
@@ -2419,11 +2364,18 @@ @@ -2420,11 +2365,18 @@
par1PlayerUsageSnooper.addData("gl_max_texture_size", Integer.valueOf(getGLMaximumTextureSize())); par1PlayerUsageSnooper.addData("gl_max_texture_size", Integer.valueOf(getGLMaximumTextureSize()));
} }
@ -277,7 +277,7 @@
for (int i = 16384; i > 0; i >>= 1) 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); 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) if (j != 0)
{ {

View file

@ -10,7 +10,7 @@
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import java.io.File; import java.io.File;
@@ -61,9 +65,11 @@ @@ -62,9 +66,11 @@
private Random rand = new Random(); private Random rand = new Random();
private int ticksBeforeMusic; private int ticksBeforeMusic;
@ -23,7 +23,7 @@
this.options = par2GameSettings; this.options = par2GameSettings;
this.fileAssets = par3File; this.fileAssets = par3File;
this.soundPoolSounds = new SoundPool(par1ResourceManager, "sound", true); this.soundPoolSounds = new SoundPool(par1ResourceManager, "sound", true);
@@ -75,6 +81,7 @@ @@ -76,6 +82,7 @@
SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class); SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class);
SoundSystemConfig.setCodec("ogg", CodecJOrbis.class); SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
SoundSystemConfig.setCodec("wav", CodecWav.class); SoundSystemConfig.setCodec("wav", CodecWav.class);
@ -31,7 +31,7 @@
} }
catch (SoundSystemException soundsystemexception) catch (SoundSystemException soundsystemexception)
{ {
@@ -90,6 +97,7 @@ @@ -92,6 +99,7 @@
this.stopAllSounds(); this.stopAllSounds();
this.cleanup(); this.cleanup();
this.tryToSetLibraryAndCodecs(); this.tryToSetLibraryAndCodecs();
@ -39,7 +39,7 @@
} }
private void loadSounds() private void loadSounds()
@@ -236,10 +244,11 @@ @@ -238,10 +246,11 @@
else else
{ {
SoundPoolEntry soundpoolentry = this.soundPoolMusic.getRandomSound(); SoundPoolEntry soundpoolentry = this.soundPoolMusic.getRandomSound();
@ -52,7 +52,7 @@
this.sndSystem.backgroundMusic("BgMusic", soundpoolentry.getSoundUrl(), soundpoolentry.getSoundName(), false); this.sndSystem.backgroundMusic("BgMusic", soundpoolentry.getSoundUrl(), soundpoolentry.getSoundName(), false);
this.sndSystem.setVolume("BgMusic", this.options.musicVolume); this.sndSystem.setVolume("BgMusic", this.options.musicVolume);
this.sndSystem.play("BgMusic"); this.sndSystem.play("BgMusic");
@@ -307,6 +316,7 @@ @@ -309,6 +318,7 @@
if (par1Str != null) if (par1Str != null)
{ {
SoundPoolEntry soundpoolentry = this.soundPoolStreaming.getRandomSoundFromSoundPool(par1Str); SoundPoolEntry soundpoolentry = this.soundPoolStreaming.getRandomSoundFromSoundPool(par1Str);
@ -60,7 +60,7 @@
if (soundpoolentry != null) 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.newStreamingSource(true, s1, soundpoolentry.getSoundUrl(), soundpoolentry.getSoundName(), false, par2, par3, par4, 2, 64.0F);
this.sndSystem.setVolume(s1, 0.5F * this.options.soundVolume); this.sndSystem.setVolume(s1, 0.5F * this.options.soundVolume);
@ -68,7 +68,7 @@
this.sndSystem.play(s1); this.sndSystem.play(s1);
} }
} }
@@ -485,6 +496,7 @@ @@ -487,6 +498,7 @@
if (this.loaded && this.options.soundVolume != 0.0F) if (this.loaded && this.options.soundVolume != 0.0F)
{ {
SoundPoolEntry soundpoolentry = this.soundPoolSounds.getRandomSoundFromSoundPool(par1Str); SoundPoolEntry soundpoolentry = this.soundPoolSounds.getRandomSoundFromSoundPool(par1Str);
@ -76,7 +76,7 @@
if (soundpoolentry != null && par5 > 0.0F) if (soundpoolentry != null && par5 > 0.0F)
{ {
@@ -506,6 +518,7 @@ @@ -508,6 +520,7 @@
this.sndSystem.setPitch(s1, par6); this.sndSystem.setPitch(s1, par6);
this.sndSystem.setVolume(s1, par5 * this.options.soundVolume); this.sndSystem.setVolume(s1, par5 * this.options.soundVolume);
@ -84,7 +84,7 @@
this.sndSystem.play(s1); this.sndSystem.play(s1);
} }
} }
@@ -520,6 +533,7 @@ @@ -522,6 +535,7 @@
if (this.loaded && this.options.soundVolume != 0.0F) if (this.loaded && this.options.soundVolume != 0.0F)
{ {
SoundPoolEntry soundpoolentry = this.soundPoolSounds.getRandomSoundFromSoundPool(par1Str); SoundPoolEntry soundpoolentry = this.soundPoolSounds.getRandomSoundFromSoundPool(par1Str);
@ -92,7 +92,7 @@
if (soundpoolentry != null && par2 > 0.0F) if (soundpoolentry != null && par2 > 0.0F)
{ {
@@ -535,6 +549,7 @@ @@ -537,6 +551,7 @@
par2 *= 0.25F; par2 *= 0.25F;
this.sndSystem.setPitch(s1, par3); this.sndSystem.setPitch(s1, par3);
this.sndSystem.setVolume(s1, par2 * this.options.soundVolume); this.sndSystem.setVolume(s1, par2 * this.options.soundVolume);

View file

@ -64,6 +64,15 @@
if (this.itemInUseCount <= 25 && this.itemInUseCount % 4 == 0) if (this.itemInUseCount <= 25 && this.itemInUseCount % 4 == 0)
{ {
this.updateItemUse(itemstack, 5); 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 @@ @@ -429,7 +449,7 @@
vec31.rotateAroundX(-this.rotationPitch * (float)Math.PI / 180.0F); vec31.rotateAroundX(-this.rotationPitch * (float)Math.PI / 180.0F);
vec31.rotateAroundY(-this.rotationYaw * (float)Math.PI / 180.0F); vec31.rotateAroundY(-this.rotationYaw * (float)Math.PI / 180.0F);

View file

@ -45,6 +45,15 @@
/** /**
* Called to update the entity's position/logic. * 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 @@ @@ -290,7 +283,10 @@
if (chunkcoordintpair != null && this.worldObj.blockExists(chunkcoordintpair.chunkXPos << 4, 0, chunkcoordintpair.chunkZPos << 4)) if (chunkcoordintpair != null && this.worldObj.blockExists(chunkcoordintpair.chunkXPos << 4, 0, chunkcoordintpair.chunkZPos << 4))
{ {