ForgePatch/patches/minecraft/net/minecraft/client/Minecraft.java.patch

534 lines
24 KiB
Diff

--- ../src-base/minecraft/net/minecraft/client/Minecraft.java
+++ ../src-work/minecraft/net/minecraft/client/Minecraft.java
@@ -321,7 +321,6 @@
this.field_152355_az = (new YggdrasilAuthenticationService(this.field_110453_aa, UUID.randomUUID().toString())).createMinecraftSessionService();
this.field_71449_j = p_i45547_1_.field_178745_a.field_178752_a;
field_147123_G.info("Setting user: " + this.field_71449_j.func_111285_a());
- field_147123_G.debug("(Session ID is " + this.field_71449_j.func_111286_b() + ")");
this.field_71459_aj = p_i45547_1_.field_178741_d.field_178756_a;
this.field_71443_c = p_i45547_1_.field_178743_b.field_178764_a > 0 ? p_i45547_1_.field_178743_b.field_178764_a : 1;
this.field_71440_d = p_i45547_1_.field_178743_b.field_178762_b > 0 ? p_i45547_1_.field_178743_b.field_178762_b : 1;
@@ -435,10 +434,10 @@
this.field_110451_am = new SimpleReloadableResourceManager(this.field_110452_an);
this.field_135017_as = new LanguageManager(this.field_110452_an, this.field_71474_y.field_74363_ab);
this.field_110451_am.func_110542_a(this.field_135017_as);
- this.func_110436_a();
+ net.minecraftforge.fml.client.FMLClientHandler.instance().beginMinecraftLoading(this, this.field_110449_ao, this.field_110451_am);
this.field_71446_o = new TextureManager(this.field_110451_am);
this.field_110451_am.func_110542_a(this.field_71446_o);
- this.func_180510_a(this.field_71446_o);
+ net.minecraftforge.fml.client.SplashProgress.drawVanillaScreen(this.field_71446_o);
this.field_152350_aA = new SkinManager(this.field_71446_o, new File(this.field_110446_Y, "skins"), this.field_152355_az);
this.field_71469_aa = new AnvilSaveConverter(new File(this.field_71412_D, "saves"), this.field_184131_U);
this.field_147127_av = new SoundHandler(this.field_110451_am, this.field_71474_y);
@@ -463,7 +462,7 @@
{
try
{
- return String.format(p_74535_1_, new Object[] {GameSettings.func_74298_c(Minecraft.this.field_71474_y.field_151445_Q.func_151463_i())});
+ return String.format(p_74535_1_, new Object[] {Minecraft.this.field_71474_y.field_151445_Q.getDisplayName()});
}
catch (Exception exception)
{
@@ -472,6 +471,8 @@
}
});
this.field_71417_B = new MouseHelper();
+ net.minecraftforge.fml.common.ProgressManager.ProgressBar bar= net.minecraftforge.fml.common.ProgressManager.push("Rendering Setup", 5, true);
+ bar.step("GL Setup");
this.func_71361_d("Pre startup");
GlStateManager.func_179098_w();
GlStateManager.func_179103_j(7425);
@@ -485,19 +486,23 @@
GlStateManager.func_179096_D();
GlStateManager.func_179128_n(5888);
this.func_71361_d("Startup");
- this.field_147128_au = new TextureMap("textures");
+ bar.step("Loading Texture Map");
+ this.field_147128_au = new TextureMap("textures", true);
this.field_147128_au.func_147633_a(this.field_71474_y.field_151442_I);
this.field_71446_o.func_110580_a(TextureMap.field_110575_b, this.field_147128_au);
this.field_71446_o.func_110577_a(TextureMap.field_110575_b);
this.field_147128_au.func_174937_a(false, this.field_71474_y.field_151442_I > 0);
+ bar.step("Loading Model Manager");
this.field_175617_aL = new ModelManager(this.field_147128_au);
this.field_110451_am.func_110542_a(this.field_175617_aL);
this.field_184127_aH = BlockColors.func_186723_a();
this.field_184128_aI = ItemColors.func_186729_a(this.field_184127_aH);
+ bar.step("Loading Item Renderer");
this.field_175621_X = new RenderItem(this.field_71446_o, this.field_175617_aL, this.field_184128_aI);
this.field_175616_W = new RenderManager(this.field_71446_o, this.field_175621_X);
this.field_175620_Y = new ItemRenderer(this);
this.field_110451_am.func_110542_a(this.field_175621_X);
+ bar.step("Loading Entity Renderer");
this.field_71460_t = new EntityRenderer(this, this.field_110451_am);
this.field_110451_am.func_110542_a(this.field_71460_t);
this.field_175618_aM = new BlockRendererDispatcher(this.field_175617_aL.func_174954_c(), this.field_184127_aH);
@@ -507,23 +512,26 @@
this.field_71458_u = new GuiAchievement(this);
GlStateManager.func_179083_b(0, 0, this.field_71443_c, this.field_71440_d);
this.field_71452_i = new ParticleManager(this.field_71441_e, this.field_71446_o);
+ net.minecraftforge.fml.common.ProgressManager.pop(bar);
+ net.minecraftforge.fml.client.FMLClientHandler.instance().finishMinecraftLoading();
this.func_71361_d("Post startup");
- this.field_71456_v = new GuiIngame(this);
+ this.field_71456_v = new net.minecraftforge.client.GuiIngameForge(this);
if (this.field_71475_ae != null)
{
- this.func_147108_a(new GuiConnecting(new GuiMainMenu(), this, this.field_71475_ae, this.field_71477_af));
+ net.minecraftforge.fml.client.FMLClientHandler.instance().connectToServerAtStartup(this.field_71475_ae, this.field_71477_af);
}
else
{
this.func_147108_a(new GuiMainMenu());
}
- this.field_71446_o.func_147645_c(this.field_152354_ay);
+ net.minecraftforge.fml.client.SplashProgress.clearVanillaResources(field_71446_o, field_152354_ay);
this.field_152354_ay = null;
this.field_71461_s = new LoadingScreenRenderer(this);
this.field_184132_p = new DebugRenderer(this);
+ net.minecraftforge.fml.client.FMLClientHandler.instance().onInitializationComplete();
if (this.field_71474_y.field_74353_u && !this.field_71431_Q)
{
this.func_71352_k();
@@ -695,21 +703,23 @@
File file2 = new File(file1, "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-client.txt");
Bootstrap.func_179870_a(p_71377_1_.func_71502_e());
+ int retVal;
if (p_71377_1_.func_71497_f() != null)
{
Bootstrap.func_179870_a("#@!@# Game crashed! Crash report saved to: #@!@# " + p_71377_1_.func_71497_f());
- System.exit(-1);
+ retVal = -1;
}
else if (p_71377_1_.func_147149_a(file2))
{
Bootstrap.func_179870_a("#@!@# Game crashed! Crash report saved to: #@!@# " + file2.getAbsolutePath());
- System.exit(-1);
+ retVal = -1;
}
else
{
Bootstrap.func_179870_a("#@?@# Game crashed! Crash report could not be saved. #@?@#");
- System.exit(-2);
+ retVal = -2;
}
+ net.minecraftforge.fml.common.FMLCommonHandler.instance().handleExit(retVal);
}
public boolean func_152349_b()
@@ -902,11 +912,6 @@
public void func_147108_a(@Nullable GuiScreen p_147108_1_)
{
- if (this.field_71462_r != null)
- {
- this.field_71462_r.func_146281_b();
- }
-
if (p_147108_1_ == null && this.field_71441_e == null)
{
p_147108_1_ = new GuiMainMenu();
@@ -916,6 +921,17 @@
p_147108_1_ = new GuiGameOver((ITextComponent)null);
}
+ GuiScreen old = this.field_71462_r;
+ net.minecraftforge.client.event.GuiOpenEvent event = new net.minecraftforge.client.event.GuiOpenEvent(p_147108_1_);
+
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return;
+
+ p_147108_1_ = event.getGui();
+ if (old != null && p_147108_1_ != old)
+ {
+ old.func_146281_b();
+ }
+
if (p_147108_1_ instanceof GuiMainMenu || p_147108_1_ instanceof GuiMultiplayer)
{
this.field_71474_y.field_74330_P = false;
@@ -1054,9 +1070,11 @@
if (!this.field_71454_w)
{
+ net.minecraftforge.fml.common.FMLCommonHandler.instance().onRenderTickStart(this.field_71428_T.field_74281_c);
this.field_71424_I.func_76318_c("gameRenderer");
this.field_71460_t.func_181560_a(this.field_71428_T.field_74281_c, i);
this.field_71424_I.func_76319_b();
+ net.minecraftforge.fml.common.FMLCommonHandler.instance().onRenderTickEnd(this.field_71428_T.field_74281_c);
}
this.field_71424_I.func_76319_b();
@@ -1396,9 +1414,9 @@
{
BlockPos blockpos = this.field_71476_x.func_178782_a();
- if (this.field_71441_e.func_180495_p(blockpos).func_185904_a() != Material.field_151579_a && this.field_71442_b.func_180512_c(blockpos, this.field_71476_x.field_178784_b))
+ if (!this.field_71441_e.func_175623_d(blockpos) && this.field_71442_b.func_180512_c(blockpos, this.field_71476_x.field_178784_b))
{
- this.field_71452_i.func_180532_a(blockpos, this.field_71476_x.field_178784_b);
+ this.field_71452_i.addBlockHitEffects(blockpos, this.field_71476_x);
this.field_71439_g.func_184609_a(EnumHand.MAIN_HAND);
}
}
@@ -1432,7 +1450,7 @@
case BLOCK:
BlockPos blockpos = this.field_71476_x.func_178782_a();
- if (this.field_71441_e.func_180495_p(blockpos).func_185904_a() != Material.field_151579_a)
+ if (!this.field_71441_e.func_175623_d(blockpos))
{
this.field_71442_b.func_180511_b(blockpos, this.field_71476_x.field_178784_b);
break;
@@ -1476,7 +1494,7 @@
switch (this.field_71476_x.field_72313_a)
{
case ENTITY:
-
+ if(!net.minecraftforge.common.ForgeHooks.onInteractEntityAt(field_71439_g, field_71476_x.field_72308_g, field_71476_x, field_71439_g.func_184586_b(enumhand), enumhand))
if (this.field_71442_b.func_187102_a(this.field_71439_g, this.field_71476_x.field_72308_g, this.field_71476_x, this.field_71439_g.func_184586_b(enumhand), enumhand) == EnumActionResult.SUCCESS)
{
return;
@@ -1519,7 +1537,7 @@
}
ItemStack itemstack1 = this.field_71439_g.func_184586_b(enumhand);
-
+ if (itemstack1 == null) net.minecraftforge.common.ForgeHooks.onEmptyClick(this.field_71439_g, enumhand);
if (itemstack1 != null && this.field_71442_b.func_187101_a(this.field_71439_g, this.field_71441_e, itemstack1, enumhand) == EnumActionResult.SUCCESS)
{
this.field_71460_t.field_78516_c.func_187460_a(enumhand);
@@ -1626,6 +1644,8 @@
--this.field_71467_ac;
}
+ net.minecraftforge.fml.common.FMLCommonHandler.instance().onPreClientTick();
+
this.field_71424_I.func_76320_a("gui");
if (!this.field_71445_n)
@@ -1737,6 +1757,7 @@
this.field_71457_ai = 0;
this.field_71441_e.func_72897_h(this.field_71439_g);
}
+ net.minecraftforge.fml.common.FMLCommonHandler.instance().fireMouseInput();
}
this.field_71424_I.func_76318_c("gameRenderer");
@@ -1824,6 +1845,7 @@
this.field_71453_ak.func_74428_b();
}
+ net.minecraftforge.fml.common.FMLCommonHandler.instance().onPostClientTick();
this.field_71424_I.func_76319_b();
this.field_71423_H = func_71386_F();
}
@@ -1930,6 +1952,7 @@
}
}
}
+ net.minecraftforge.fml.common.FMLCommonHandler.instance().fireKeyInput();
}
this.func_184117_aA();
@@ -2169,6 +2192,8 @@
{
while (Mouse.next())
{
+ if (net.minecraftforge.client.ForgeHooksClient.postMouseEvent()) continue;
+
int i = Mouse.getEventButton();
KeyBinding.func_74510_a(i - 100, Mouse.getEventButtonState());
@@ -2234,6 +2259,7 @@
public void func_71371_a(String p_71371_1_, String p_71371_2_, @Nullable WorldSettings p_71371_3_)
{
+ net.minecraftforge.fml.client.FMLClientHandler.instance().startIntegratedServer(p_71371_1_, p_71371_2_, p_71371_3_);
this.func_71403_a((WorldClient)null);
System.gc();
ISaveHandler isavehandler = this.field_71469_aa.func_75804_a(p_71371_1_, false);
@@ -2276,6 +2302,12 @@
while (!this.field_71437_Z.func_71200_ad())
{
+ if (!net.minecraftforge.fml.common.StartupQuery.check())
+ {
+ func_71403_a(null);
+ func_147108_a(null);
+ return;
+ }
String s = this.field_71437_Z.func_71195_b_();
if (s != null)
@@ -2301,8 +2333,14 @@
SocketAddress socketaddress = this.field_71437_Z.func_147137_ag().func_151270_a();
NetworkManager networkmanager = NetworkManager.func_150722_a(socketaddress);
networkmanager.func_150719_a(new NetHandlerLoginClient(networkmanager, this, (GuiScreen)null));
- networkmanager.func_179290_a(new C00Handshake(110, socketaddress.toString(), 0, EnumConnectionState.LOGIN));
- networkmanager.func_179290_a(new CPacketLoginStart(this.func_110432_I().func_148256_e()));
+ networkmanager.func_179290_a(new C00Handshake(110, socketaddress.toString(), 0, EnumConnectionState.LOGIN, true));
+ com.mojang.authlib.GameProfile gameProfile = this.func_110432_I().func_148256_e();
+ if (!this.func_110432_I().hasCachedProperties())
+ {
+ gameProfile = field_152355_az.fillProfileProperties(gameProfile, true); //Forge: Fill profile properties upon game load. Fixes MC-52974.
+ this.func_110432_I().setProperties(gameProfile.getProperties());
+ }
+ networkmanager.func_179290_a(new CPacketLoginStart(gameProfile));
this.field_71453_ak = networkmanager;
}
@@ -2313,6 +2351,8 @@
public void func_71353_a(@Nullable WorldClient p_71353_1_, String p_71353_2_)
{
+ if (field_71441_e != null) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(field_71441_e));
+
if (p_71353_1_ == null)
{
NetHandlerPlayClient nethandlerplayclient = this.func_147114_u();
@@ -2325,6 +2365,18 @@
if (this.field_71437_Z != null && this.field_71437_Z.func_175578_N())
{
this.field_71437_Z.func_71263_m();
+ if (field_71461_s != null)
+ {
+ this.field_71461_s.func_73719_c(I18n.func_135052_a("forge.client.shutdown.internal"));
+ }
+ while (!field_71437_Z.func_71241_aa())
+ {
+ try
+ {
+ Thread.sleep(10);
+ }
+ catch (InterruptedException ie) {}
+ }
}
this.field_71437_Z = null;
@@ -2348,6 +2400,7 @@
this.field_71456_v.func_181029_i();
this.func_71351_a((ServerData)null);
this.field_71455_al = false;
+ net.minecraftforge.fml.client.FMLClientHandler.instance().handleClientWorldClosing(this.field_71441_e);
}
this.field_147127_av.func_147690_c();
@@ -2464,159 +2517,8 @@
{
if (this.field_71476_x != null && this.field_71476_x.field_72313_a != RayTraceResult.Type.MISS)
{
- boolean flag = this.field_71439_g.field_71075_bZ.field_75098_d;
- TileEntity tileentity = null;
- ItemStack itemstack;
-
- if (this.field_71476_x.field_72313_a == RayTraceResult.Type.BLOCK)
- {
- BlockPos blockpos = this.field_71476_x.func_178782_a();
- IBlockState iblockstate = this.field_71441_e.func_180495_p(blockpos);
- Block block = iblockstate.func_177230_c();
-
- if (iblockstate.func_185904_a() == Material.field_151579_a)
- {
- return;
- }
-
- itemstack = block.func_185473_a(this.field_71441_e, blockpos, iblockstate);
-
- if (itemstack == null)
- {
- return;
- }
-
- if (flag && GuiScreen.func_146271_m() && block.func_149716_u())
- {
- tileentity = this.field_71441_e.func_175625_s(blockpos);
- }
- }
- else
- {
- if (this.field_71476_x.field_72313_a != RayTraceResult.Type.ENTITY || this.field_71476_x.field_72308_g == null || !flag)
- {
- return;
- }
-
- if (this.field_71476_x.field_72308_g instanceof EntityPainting)
- {
- itemstack = new ItemStack(Items.field_151159_an);
- }
- else if (this.field_71476_x.field_72308_g instanceof EntityLeashKnot)
- {
- itemstack = new ItemStack(Items.field_151058_ca);
- }
- else if (this.field_71476_x.field_72308_g instanceof EntityItemFrame)
- {
- EntityItemFrame entityitemframe = (EntityItemFrame)this.field_71476_x.field_72308_g;
- ItemStack itemstack1 = entityitemframe.func_82335_i();
-
- if (itemstack1 == null)
- {
- itemstack = new ItemStack(Items.field_151160_bD);
- }
- else
- {
- itemstack = ItemStack.func_77944_b(itemstack1);
- }
- }
- else if (this.field_71476_x.field_72308_g instanceof EntityMinecart)
- {
- EntityMinecart entityminecart = (EntityMinecart)this.field_71476_x.field_72308_g;
- Item item;
-
- switch (entityminecart.func_184264_v())
- {
- case FURNACE:
- item = Items.field_151109_aJ;
- break;
- case CHEST:
- item = Items.field_151108_aI;
- break;
- case TNT:
- item = Items.field_151142_bV;
- break;
- case HOPPER:
- item = Items.field_151140_bW;
- break;
- case COMMAND_BLOCK:
- item = Items.field_151095_cc;
- break;
- default:
- item = Items.field_151143_au;
- }
-
- itemstack = new ItemStack(item);
- }
- else if (this.field_71476_x.field_72308_g instanceof EntityBoat)
- {
- itemstack = new ItemStack(((EntityBoat)this.field_71476_x.field_72308_g).func_184455_j());
- }
- else if (this.field_71476_x.field_72308_g instanceof EntityArmorStand)
- {
- itemstack = new ItemStack(Items.field_179565_cj);
- }
- else if (this.field_71476_x.field_72308_g instanceof EntityEnderCrystal)
- {
- itemstack = new ItemStack(Items.field_185158_cP);
- }
- else
- {
- String s = EntityList.func_75621_b(this.field_71476_x.field_72308_g);
-
- if (!EntityList.field_75627_a.containsKey(s))
- {
- return;
- }
-
- itemstack = new ItemStack(Items.field_151063_bx);
- ItemMonsterPlacer.func_185078_a(itemstack, s);
- }
- }
-
- if (itemstack.func_77973_b() == null)
- {
- String s1 = "";
-
- if (this.field_71476_x.field_72313_a == RayTraceResult.Type.BLOCK)
- {
- s1 = ((ResourceLocation)Block.field_149771_c.func_177774_c(this.field_71441_e.func_180495_p(this.field_71476_x.func_178782_a()).func_177230_c())).toString();
- }
- else if (this.field_71476_x.field_72313_a == RayTraceResult.Type.ENTITY)
- {
- s1 = EntityList.func_75621_b(this.field_71476_x.field_72308_g);
- }
-
- field_147123_G.warn("Picking on: [{}] {} gave null item", new Object[] {this.field_71476_x.field_72313_a, s1});
- }
- else
- {
- InventoryPlayer inventoryplayer = this.field_71439_g.field_71071_by;
-
- if (tileentity != null)
- {
- this.func_184119_a(itemstack, tileentity);
- }
-
- int i = inventoryplayer.func_184429_b(itemstack);
-
- if (flag)
- {
- inventoryplayer.func_184434_a(itemstack);
- this.field_71442_b.func_78761_a(this.field_71439_g.func_184586_b(EnumHand.MAIN_HAND), 36 + inventoryplayer.field_70461_c);
- }
- else if (i != -1)
- {
- if (InventoryPlayer.func_184435_e(i))
- {
- inventoryplayer.field_70461_c = i;
- }
- else
- {
- this.field_71442_b.func_187100_a(i);
- }
- }
- }
+ net.minecraftforge.common.ForgeHooks.onPickBlock(this.field_71476_x, this.field_71439_g, this.field_71441_e);
+ // We delete this code wholly instead of commenting it out, to make sure we detect changes in it between MC versions
}
}
@@ -2912,18 +2814,8 @@
public static int func_71369_N()
{
- for (int i = 16384; i > 0; i >>= 1)
- {
- GlStateManager.func_187419_a(32868, 0, 6408, i, i, 0, 6408, 5121, (IntBuffer)null);
- int j = GlStateManager.func_187411_c(32868, 0, 4096);
-
- if (j != 0)
- {
- return i;
- }
- }
-
- return -1;
+ //Forge we redirect this to our code which caches the value before any splash screen stuff is done.
+ return net.minecraftforge.fml.client.SplashProgress.getMaxTextureSize();
}
public boolean func_70002_Q()
@@ -3060,15 +2952,16 @@
{
if (Keyboard.getEventKeyState())
{
- if (i == this.field_71474_y.field_152395_am.func_151463_i())
+ if (this.field_71474_y.field_152395_am.isActiveAndMatches(i))
{
this.func_71352_k();
}
- else if (i == this.field_71474_y.field_151447_Z.func_151463_i())
+ else if (this.field_71474_y.field_151447_Z.isActiveAndMatches(i))
{
this.field_71456_v.func_146158_b().func_146227_a(ScreenShotHelper.func_148260_a(this.field_71412_D, this.field_71443_c, this.field_71440_d, this.field_147124_at));
}
}
+ else if (this.field_71462_r instanceof GuiControls) ((GuiControls)this.field_71462_r).field_146491_f = null;
}
}
}
@@ -3195,4 +3088,10 @@
{
return this.field_184127_aH;
}
+
+ // FORGE
+ public ItemColors getItemColors()
+ {
+ return this.field_184128_aI;
+ }
}