ForgePatch/patches/minecraft/net/minecraft/client/Minecraft.java.patch
LexManos 2c05258205 Update to 1.5.2 PR.
MinecraftForge/FML@f0bba74a47 Update for minecraft 1.5.2
MinecraftForge/FML@62fdbad74c Update MCP's md5 for the fixed srg files.
2013-04-28 13:28:40 -07:00

220 lines
8.2 KiB
Diff

--- ../src_base/minecraft/net/minecraft/client/Minecraft.java
+++ ../src_work/minecraft/net/minecraft/client/Minecraft.java
@@ -123,6 +123,13 @@
import com.google.common.collect.MapDifference;
+import net.minecraftforge.client.GuiIngameForge;
+import net.minecraftforge.common.ForgeHooks;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.ForgeEventFactory;
+import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
+import net.minecraftforge.event.world.WorldEvent;
+
@SideOnly(Side.CLIENT)
public abstract class Minecraft implements Runnable, IPlayerUsage
{
@@ -450,7 +457,7 @@
}
this.checkGLError("Post startup");
- this.ingameGUI = new GuiIngame(this);
+ this.ingameGUI = new GuiIngameForge(this);
if (this.serverName != null)
{
@@ -1238,7 +1245,7 @@
if (this.thePlayer.canCurrentToolHarvestBlock(j, k, l))
{
- this.effectRenderer.addBlockHitEffects(j, k, l, this.objectMouseOver.sideHit);
+ this.effectRenderer.addBlockHitEffects(j, k, l, this.objectMouseOver);
this.thePlayer.swingItem();
}
}
@@ -1304,7 +1311,8 @@
{
int j1 = itemstack != null ? itemstack.stackSize : 0;
- if (this.playerController.onPlayerRightClick(this.thePlayer, this.theWorld, itemstack, j, k, l, i1, this.objectMouseOver.hitVec))
+ boolean result = !ForgeEventFactory.onPlayerInteract(thePlayer, Action.RIGHT_CLICK_BLOCK, j, k, l, i1).isCanceled();
+ if (result && this.playerController.onPlayerRightClick(this.thePlayer, this.theWorld, itemstack, j, k, l, i1, this.objectMouseOver.hitVec))
{
flag = false;
this.thePlayer.swingItem();
@@ -1330,7 +1338,8 @@
{
ItemStack itemstack1 = this.thePlayer.inventory.getCurrentItem();
- if (itemstack1 != null && this.playerController.sendUseItem(this.thePlayer, this.theWorld, itemstack1))
+ boolean result = !ForgeEventFactory.onPlayerInteract(thePlayer, Action.RIGHT_CLICK_AIR, 0, 0, 0, -1).isCanceled();
+ if (result && itemstack1 != null && this.playerController.sendUseItem(this.thePlayer, this.theWorld, itemstack1))
{
this.entityRenderer.itemRenderer.resetEquippedProgress2();
}
@@ -2010,6 +2019,11 @@
{
this.statFileWriter.syncStats();
+ if (theWorld != null)
+ {
+ MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(theWorld));
+ }
+
if (par1WorldClient == null)
{
NetClientHandler netclienthandler = this.getNetHandler();
@@ -2027,6 +2041,18 @@
if (this.theIntegratedServer != null)
{
this.theIntegratedServer.initiateShutdown();
+ if (loadingScreen!=null)
+ {
+ this.loadingScreen.resetProgresAndWorkingMessage("Shutting down internal server...");
+ }
+ while (!theIntegratedServer.isServerStopped())
+ {
+ try
+ {
+ Thread.sleep(10);
+ }
+ catch (InterruptedException ie) {}
+ }
}
this.theIntegratedServer = null;
@@ -2354,103 +2380,12 @@
if (this.objectMouseOver != null)
{
boolean flag = this.thePlayer.capabilities.isCreativeMode;
- int i = 0;
- boolean flag1 = false;
- int j;
int k;
- if (this.objectMouseOver.typeOfHit == EnumMovingObjectType.TILE)
- {
- k = this.objectMouseOver.blockX;
- int l = this.objectMouseOver.blockY;
- int i1 = this.objectMouseOver.blockZ;
- Block block = Block.blocksList[this.theWorld.getBlockId(k, l, i1)];
-
- if (block == null)
- {
- return;
- }
-
- j = block.idPicked(this.theWorld, k, l, i1);
-
- if (j == 0)
- {
- return;
- }
-
- flag1 = Item.itemsList[j].getHasSubtypes();
- int j1 = j < 256 && !Block.blocksList[block.blockID].isFlowerPot() ? j : block.blockID;
- i = Block.blocksList[j1].getDamageValue(this.theWorld, k, l, i1);
- }
- else
- {
- if (this.objectMouseOver.typeOfHit != EnumMovingObjectType.ENTITY || this.objectMouseOver.entityHit == null || !flag)
- {
- return;
- }
-
- if (this.objectMouseOver.entityHit instanceof EntityPainting)
- {
- j = Item.painting.itemID;
- }
- else if (this.objectMouseOver.entityHit instanceof EntityItemFrame)
- {
- EntityItemFrame entityitemframe = (EntityItemFrame)this.objectMouseOver.entityHit;
-
- if (entityitemframe.getDisplayedItem() == null)
- {
- j = Item.itemFrame.itemID;
- }
- else
- {
- j = entityitemframe.getDisplayedItem().itemID;
- i = entityitemframe.getDisplayedItem().getItemDamage();
- flag1 = true;
- }
- }
- else if (this.objectMouseOver.entityHit instanceof EntityMinecart)
- {
- EntityMinecart entityminecart = (EntityMinecart)this.objectMouseOver.entityHit;
-
- if (entityminecart.getMinecartType() == 2)
- {
- j = Item.minecartPowered.itemID;
- }
- else if (entityminecart.getMinecartType() == 1)
- {
- j = Item.minecartCrate.itemID;
- }
- else if (entityminecart.getMinecartType() == 3)
- {
- j = Item.minecartTnt.itemID;
- }
- else if (entityminecart.getMinecartType() == 5)
- {
- j = Item.minecartHopper.itemID;
- }
- else
- {
- j = Item.minecartEmpty.itemID;
- }
- }
- else if (this.objectMouseOver.entityHit instanceof EntityBoat)
- {
- j = Item.boat.itemID;
- }
- else
- {
- j = Item.monsterPlacer.itemID;
- i = EntityList.getEntityID(this.objectMouseOver.entityHit);
- flag1 = true;
-
- if (i <= 0 || !EntityList.entityEggs.containsKey(Integer.valueOf(i)))
- {
- return;
- }
- }
- }
-
- this.thePlayer.inventory.setCurrentItem(j, i, flag1, flag);
+ if (!ForgeHooks.onPickBlock(this.objectMouseOver, this.thePlayer, this.theWorld))
+ {
+ return;
+ }
if (flag)
{
@@ -2539,11 +2474,18 @@
par1PlayerUsageSnooper.addData("gl_max_texture_size", Integer.valueOf(getGLMaximumTextureSize()));
}
+ //Forge: Adds a optimization to the getGLMaximumTextureSize, only calculate it once.
+ private static int max_texture_size = -1;
/**
* Used in the usage snooper.
*/
public static int getGLMaximumTextureSize()
{
+ if (max_texture_size != -1)
+ {
+ return max_texture_size;
+ }
+
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);
@@ -2551,6 +2493,7 @@
if (j != 0)
{
+ max_texture_size = i;
return i;
}
}