mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 04:09:51 +00:00
288 lines
10 KiB
Diff
288 lines
10 KiB
Diff
--- ../src_base/minecraft/net/minecraft/client/Minecraft.java
|
|
+++ ../src_work/minecraft/net/minecraft/client/Minecraft.java
|
|
@@ -137,6 +137,16 @@
|
|
|
|
import com.google.common.collect.MapDifference;
|
|
|
|
+import net.minecraftforge.client.ClientCommandHandler;
|
|
+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;
|
|
+import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
|
|
+import net.minecraftforge.event.world.WorldEvent;
|
|
+
|
|
@SideOnly(Side.CLIENT)
|
|
public class Minecraft implements IPlayerUsage
|
|
{
|
|
@@ -416,7 +426,7 @@
|
|
|
|
try
|
|
{
|
|
- Display.create((new PixelFormat()).withDepthBits(24));
|
|
+ ForgeHooksClient.createDisplay();
|
|
}
|
|
catch (LWJGLException lwjglexception)
|
|
{
|
|
@@ -498,7 +508,7 @@
|
|
this.effectRenderer = new EffectRenderer(this.theWorld, this.renderEngine);
|
|
FMLClientHandler.instance().finishMinecraftLoading();
|
|
this.checkGLError("Post startup");
|
|
- this.ingameGUI = new GuiIngame(this);
|
|
+ this.ingameGUI = new GuiIngameForge(this);
|
|
|
|
if (this.serverName != null)
|
|
{
|
|
@@ -680,11 +690,6 @@
|
|
*/
|
|
public void displayGuiScreen(GuiScreen par1GuiScreen)
|
|
{
|
|
- if (this.currentScreen != null)
|
|
- {
|
|
- this.currentScreen.onGuiClosed();
|
|
- }
|
|
-
|
|
this.statFileWriter.syncStats();
|
|
|
|
if (par1GuiScreen == null && this.theWorld == null)
|
|
@@ -694,6 +699,20 @@
|
|
else if (par1GuiScreen == null && this.thePlayer.getHealth() <= 0.0F)
|
|
{
|
|
par1GuiScreen = new GuiGameOver();
|
|
+ }
|
|
+
|
|
+ GuiScreen old = this.currentScreen;
|
|
+ GuiOpenEvent event = new GuiOpenEvent(par1GuiScreen);
|
|
+
|
|
+ if (MinecraftForge.EVENT_BUS.post(event))
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ par1GuiScreen = event.gui;
|
|
+ if (old != null && par1GuiScreen != old)
|
|
+ {
|
|
+ old.onGuiClosed();
|
|
}
|
|
|
|
if (par1GuiScreen instanceof GuiMainMenu)
|
|
@@ -1301,7 +1320,7 @@
|
|
|
|
if (this.thePlayer.isCurrentToolAdventureModeExempt(j, k, l))
|
|
{
|
|
- this.effectRenderer.addBlockHitEffects(j, k, l, this.objectMouseOver.sideHit);
|
|
+ this.effectRenderer.addBlockHitEffects(j, k, l, this.objectMouseOver);
|
|
this.thePlayer.swingItem();
|
|
}
|
|
}
|
|
@@ -1367,7 +1386,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();
|
|
@@ -1393,7 +1413,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();
|
|
}
|
|
@@ -1575,6 +1596,8 @@
|
|
|
|
while (Mouse.next())
|
|
{
|
|
+ if (ForgeHooksClient.postMouseEvent()) continue;
|
|
+
|
|
i = Mouse.getEventButton();
|
|
|
|
if (isRunningOnMac && i == 0 && (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)))
|
|
@@ -2047,6 +2070,11 @@
|
|
{
|
|
this.statFileWriter.syncStats();
|
|
|
|
+ if (theWorld != null)
|
|
+ {
|
|
+ MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(theWorld));
|
|
+ }
|
|
+
|
|
if (par1WorldClient == null)
|
|
{
|
|
NetClientHandler netclienthandler = this.getNetHandler();
|
|
@@ -2064,6 +2092,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;
|
|
@@ -2226,7 +2266,7 @@
|
|
*/
|
|
public boolean handleClientCommand(String par1Str)
|
|
{
|
|
- return false;
|
|
+ return ClientCommandHandler.instance.executeCommand(thePlayer, par1Str) == 1;
|
|
}
|
|
|
|
/**
|
|
@@ -2237,107 +2277,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 EntityLeashKnot)
|
|
- {
|
|
- j = Item.leash.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)
|
|
{
|
|
@@ -2420,11 +2365,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);
|
|
@@ -2432,6 +2384,7 @@
|
|
|
|
if (j != 0)
|
|
{
|
|
+ max_texture_size = i;
|
|
return i;
|
|
}
|
|
}
|