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

370 lines
17 KiB
Diff

--- a/net/minecraft/client/Minecraft.java
+++ b/net/minecraft/client/Minecraft.java
@@ -316,6 +316,7 @@
super("Client");
this.field_195556_O = p_i45547_1_.field_178743_b;
field_71432_P = this;
+ net.minecraftforge.client.ForgeHooksClient.invalidateLog4jThreadCache();
this.field_71412_D = p_i45547_1_.field_178744_c.field_178760_a;
this.field_110446_Y = p_i45547_1_.field_178744_c.field_178759_c;
this.field_130070_K = p_i45547_1_.field_178744_c.field_178758_b;
@@ -333,7 +334,7 @@
supplier = p_213262_2_;
}
- return new ClientResourcePackInfo(p_213262_0_, p_213262_1_, supplier, p_213262_3_, p_213262_4_, p_213262_5_);
+ return new ClientResourcePackInfo(p_213262_0_, p_213262_1_, supplier, p_213262_3_, p_213262_4_, p_213262_5_, p_213262_3_.isHidden());
});
this.field_110448_aq.func_198982_a(this.field_195554_ax);
this.field_110448_aq.func_198982_a(new FolderPackFinder(this.field_130070_K));
@@ -341,7 +342,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: {}", (Object)this.field_71449_j.func_111285_a());
- field_147123_G.debug("(Session ID is {})", (Object)this.field_71449_j.func_111286_b());
this.field_71459_aj = p_i45547_1_.field_178741_d.field_178756_a;
this.field_147129_ai = func_147122_X();
this.field_71437_Z = null;
@@ -451,6 +451,7 @@
this.field_147124_at.func_147604_a(0.0F, 0.0F, 0.0F, 0.0F);
this.field_110451_am = new SimpleReloadableResourceManager(ResourcePackType.CLIENT_RESOURCES, this.field_152352_aC);
this.field_71474_y.func_198017_a(this.field_110448_aq);
+ net.minecraftforge.fml.client.ClientModLoader.begin(this, this.field_110448_aq, this.field_110451_am, this.field_195554_ax);
this.field_110448_aq.func_198983_a();
List<IResourcePack> list = this.field_110448_aq.func_198980_d().stream().map(ResourcePackInfo::func_195796_e).collect(Collectors.toList());
@@ -521,7 +522,7 @@
this.field_110451_am.func_219534_a(this.field_213272_aL);
this.field_213273_aM = new PotionSpriteUploader(this.field_71446_o);
this.field_110451_am.func_219534_a(this.field_213273_aM);
- this.field_71456_v = new IngameGui(this);
+ this.field_71456_v = new net.minecraftforge.client.ForgeIngameGui(this);
this.field_184132_p = new DebugRenderer(this);
GLX.setGlfwErrorCallback(this::func_195545_a);
if (this.field_71474_y.field_74353_u && !this.field_195558_d.func_198113_j()) {
@@ -542,7 +543,7 @@
if (SharedConstants.field_206244_b) {
this.func_213256_aB();
}
-
+ net.minecraftforge.fml.client.ClientModLoader.complete();
}, false));
}
@@ -557,7 +558,7 @@
return Stream.of(Registry.field_212630_s.func_177774_c(p_213251_0_.func_77973_b()));
});
SearchTreeReloadable<ItemStack> searchtreereloadable = new SearchTreeReloadable<>((p_213235_0_) -> {
- return ItemTags.func_199903_a().func_199913_a(p_213235_0_.func_77973_b()).stream();
+ return p_213235_0_.func_77973_b().getTags().stream();
});
NonNullList<ItemStack> nonnulllist = NonNullList.func_191196_a();
@@ -646,7 +647,7 @@
Bootstrap.func_179870_a(p_71377_1_.func_71502_e());
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);
+ net.minecraftforge.fml.server.ServerLifecycleHooks.handleExit(-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);
@@ -661,6 +662,7 @@
return this.field_71474_y.field_211842_aO;
}
+ @Deprecated // Forge: Use selective refreshResources method in FMLClientHandler
public CompletableFuture<Void> func_213237_g() {
if (this.field_213276_aV != null) {
return this.field_213276_aV;
@@ -740,16 +742,20 @@
}
public void func_147108_a(@Nullable Screen p_147108_1_) {
- if (this.field_71462_r != null) {
- this.field_71462_r.removed();
- }
-
if (p_147108_1_ == null && this.field_71441_e == null) {
p_147108_1_ = new MainMenuScreen();
} else if (p_147108_1_ == null && this.field_71439_g.func_110143_aJ() <= 0.0F) {
p_147108_1_ = new DeathScreen((ITextComponent)null, this.field_71441_e.func_72912_H().func_76093_s());
}
+ Screen 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.removed();
+
if (p_147108_1_ instanceof MainMenuScreen || p_147108_1_ instanceof MultiplayerScreen) {
this.field_71474_y.field_74330_P = false;
this.field_71456_v.func_146158_b().func_146231_a(true);
@@ -874,11 +880,13 @@
GlStateManager.enableTexture();
this.field_71424_I.func_76319_b();
if (!this.field_71454_w) {
+ net.minecraftforge.fml.hooks.BasicEventHooks.onRenderTickStart(this.field_71428_T.field_194147_b);
this.field_71424_I.func_219895_b("gameRenderer");
this.field_71460_t.func_195458_a(this.field_71445_n ? this.field_193996_ah : this.field_71428_T.field_194147_b, i, p_195542_1_);
this.field_71424_I.func_219895_b("toasts");
this.field_193034_aS.func_195625_a();
this.field_71424_I.func_76319_b();
+ net.minecraftforge.fml.hooks.BasicEventHooks.onRenderTickEnd(this.field_71428_T.field_194147_b);
}
this.field_71424_I.func_219897_b();
@@ -1146,10 +1154,10 @@
if (p_147115_1_ && this.field_71476_x != null && this.field_71476_x.func_216346_c() == RayTraceResult.Type.BLOCK) {
BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult)this.field_71476_x;
BlockPos blockpos = blockraytraceresult.func_216350_a();
- if (!this.field_71441_e.func_180495_p(blockpos).func_196958_f()) {
+ if (!this.field_71441_e.func_175623_d(blockpos)) {
Direction direction = blockraytraceresult.func_216354_b();
if (this.field_71442_b.func_180512_c(blockpos, direction)) {
- this.field_71452_i.func_180532_a(blockpos, direction);
+ this.field_71452_i.addBlockHitEffects(blockpos, blockraytraceresult);
this.field_71439_g.func_184609_a(Hand.MAIN_HAND);
}
}
@@ -1176,7 +1184,7 @@
case BLOCK:
BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult)this.field_71476_x;
BlockPos blockpos = blockraytraceresult.func_216350_a();
- if (!this.field_71441_e.func_180495_p(blockpos).func_196958_f()) {
+ if (!this.field_71441_e.func_180495_p(blockpos).isAir(field_71441_e, blockpos)) {
this.field_71442_b.func_180511_b(blockpos, blockraytraceresult.func_216354_b());
break;
}
@@ -1186,6 +1194,7 @@
}
this.field_71439_g.func_184821_cY();
+ net.minecraftforge.common.ForgeHooks.onEmptyLeftClick(this.field_71439_g);
}
this.field_71439_g.func_184609_a(Hand.MAIN_HAND);
@@ -1235,6 +1244,9 @@
}
}
+ if (itemstack.func_190926_b() && (this.field_71476_x == null || this.field_71476_x.func_216346_c() == RayTraceResult.Type.MISS))
+ net.minecraftforge.common.ForgeHooks.onEmptyClick(this.field_71439_g, hand);
+
if (!itemstack.func_190926_b() && this.field_71442_b.func_187101_a(this.field_71439_g, this.field_71441_e, hand) == ActionResultType.SUCCESS) {
this.field_71460_t.field_78516_c.func_187460_a(hand);
return;
@@ -1254,6 +1266,8 @@
--this.field_71467_ac;
}
+ net.minecraftforge.fml.hooks.BasicEventHooks.onPreClientTick();
+
this.field_71424_I.func_76320_a("gui");
if (!this.field_71445_n) {
this.field_71456_v.func_73831_a();
@@ -1372,6 +1386,8 @@
this.field_71424_I.func_219895_b("keyboard");
this.field_195559_v.func_204870_b();
this.field_71424_I.func_76319_b();
+
+ net.minecraftforge.fml.hooks.BasicEventHooks.onPostClientTick();
}
private void func_184117_aA() {
@@ -1526,6 +1542,12 @@
this.func_147108_a(worldloadprogressscreen);
while(!this.field_71437_Z.func_71200_ad()) {
+ if (!net.minecraftforge.fml.StartupQuery.check() || this.field_71437_Z.func_71241_aa()) {
+ this.func_147108_a(null);
+ return;
+ } else if (this.field_71462_r == null) // if we're showing nothing, put the working screen back again
+ this.func_147108_a(worldloadprogressscreen);
+
worldloadprogressscreen.tick();
this.func_195542_b(false);
@@ -1546,11 +1568,17 @@
networkmanager.func_150719_a(new ClientLoginNetHandler(networkmanager, this, (Screen)null, (p_213261_0_) -> {
}));
networkmanager.func_179290_a(new CHandshakePacket(socketaddress.toString(), 0, ProtocolType.LOGIN));
- networkmanager.func_179290_a(new CLoginStartPacket(this.func_110432_I().func_148256_e()));
+ 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 CLoginStartPacket(gameProfile));
this.field_71453_ak = networkmanager;
}
public void func_71403_a(ClientWorld p_71403_1_) {
+ if (field_71441_e != null) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(field_71441_e));
WorkingScreen workingscreen = new WorkingScreen();
workingscreen.func_200210_a(new TranslationTextComponent("connect.joining"));
this.func_213241_c(workingscreen);
@@ -1586,6 +1614,7 @@
NarratorChatListener.field_193643_a.func_193642_b();
this.func_213241_c(p_213231_1_);
if (this.field_71441_e != null) {
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(field_71441_e));
if (integratedserver != null) {
while(!integratedserver.func_213201_w()) {
this.func_195542_b(false);
@@ -1623,6 +1652,7 @@
}
TileEntityRendererDispatcher.field_147556_a.func_147543_a(p_213257_1_);
+ net.minecraftforge.client.MinecraftForgeClient.clearRenderCache();
}
public final boolean func_71355_q() {
@@ -1648,112 +1678,8 @@
private void func_147112_ai() {
if (this.field_71476_x != null && this.field_71476_x.func_216346_c() != RayTraceResult.Type.MISS) {
- boolean flag = this.field_71439_g.field_71075_bZ.field_75098_d;
- TileEntity tileentity = null;
- RayTraceResult.Type raytraceresult$type = this.field_71476_x.func_216346_c();
- ItemStack itemstack;
- if (raytraceresult$type == RayTraceResult.Type.BLOCK) {
- BlockPos blockpos = ((BlockRayTraceResult)this.field_71476_x).func_216350_a();
- BlockState blockstate = this.field_71441_e.func_180495_p(blockpos);
- Block block = blockstate.func_177230_c();
- if (blockstate.func_196958_f()) {
- return;
- }
-
- itemstack = block.func_185473_a(this.field_71441_e, blockpos, blockstate);
- if (itemstack.func_190926_b()) {
- return;
- }
-
- if (flag && Screen.hasControlDown() && block.func_149716_u()) {
- tileentity = this.field_71441_e.func_175625_s(blockpos);
- }
- } else {
- if (raytraceresult$type != RayTraceResult.Type.ENTITY || !flag) {
- return;
- }
-
- Entity entity = ((EntityRayTraceResult)this.field_71476_x).func_216348_a();
- if (entity instanceof PaintingEntity) {
- itemstack = new ItemStack(Items.field_151159_an);
- } else if (entity instanceof LeashKnotEntity) {
- itemstack = new ItemStack(Items.field_151058_ca);
- } else if (entity instanceof ItemFrameEntity) {
- ItemFrameEntity itemframeentity = (ItemFrameEntity)entity;
- ItemStack itemstack1 = itemframeentity.func_82335_i();
- if (itemstack1.func_190926_b()) {
- itemstack = new ItemStack(Items.field_151160_bD);
- } else {
- itemstack = itemstack1.func_77946_l();
- }
- } else if (entity instanceof AbstractMinecartEntity) {
- AbstractMinecartEntity abstractminecartentity = (AbstractMinecartEntity)entity;
- Item item;
- switch(abstractminecartentity.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 (entity instanceof BoatEntity) {
- itemstack = new ItemStack(((BoatEntity)entity).func_184455_j());
- } else if (entity instanceof ArmorStandEntity) {
- itemstack = new ItemStack(Items.field_179565_cj);
- } else if (entity instanceof EnderCrystalEntity) {
- itemstack = new ItemStack(Items.field_185158_cP);
- } else {
- SpawnEggItem spawneggitem = SpawnEggItem.func_200889_b(entity.func_200600_R());
- if (spawneggitem == null) {
- return;
- }
-
- itemstack = new ItemStack(spawneggitem);
- }
- }
-
- if (itemstack.func_190926_b()) {
- String s = "";
- if (raytraceresult$type == RayTraceResult.Type.BLOCK) {
- s = Registry.field_212618_g.func_177774_c(this.field_71441_e.func_180495_p(((BlockRayTraceResult)this.field_71476_x).func_216350_a()).func_177230_c()).toString();
- } else if (raytraceresult$type == RayTraceResult.Type.ENTITY) {
- s = Registry.field_212629_r.func_177774_c(((EntityRayTraceResult)this.field_71476_x).func_216348_a().func_200600_R()).toString();
- }
-
- field_147123_G.warn("Picking on: [{}] {} gave null item", raytraceresult$type, s);
- } else {
- PlayerInventory playerinventory = this.field_71439_g.field_71071_by;
- if (tileentity != null) {
- this.func_184119_a(itemstack, tileentity);
- }
-
- int i = playerinventory.func_184429_b(itemstack);
- if (flag) {
- playerinventory.func_184434_a(itemstack);
- this.field_71442_b.func_78761_a(this.field_71439_g.func_184586_b(Hand.MAIN_HAND), 36 + playerinventory.field_70461_c);
- } else if (i != -1) {
- if (PlayerInventory.func_184435_e(i)) {
- playerinventory.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
}
}
@@ -1825,6 +1751,7 @@
return field_71432_P;
}
+ @Deprecated // Forge: Use selective scheduleResourceRefresh method in FMLClientHandler
public CompletableFuture<Void> func_213245_w() {
return this.func_213169_a(this::func_213237_g).thenCompose((p_213240_0_) -> {
return p_213240_0_;
@@ -1968,6 +1895,8 @@
}
public MusicTicker.MusicType func_147109_W() {
+ MusicTicker.MusicType type = this.field_71441_e == null || this.field_71441_e.field_73011_w == null ? null : this.field_71441_e.field_73011_w.getMusicType();
+ if (type != null) return type;
if (this.field_71462_r instanceof WinGameScreen) {
return MusicTicker.MusicType.CREDITS;
} else if (this.field_71439_g == null) {
@@ -2124,4 +2053,12 @@
public LoadingGui func_213250_au() {
return this.field_213279_p;
}
+
+ public ItemColors getItemColors() {
+ return this.field_184128_aI;
+ }
+
+ public SearchTreeManager getSearchTreeManager() {
+ return this.field_193995_ae;
+ }
}