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

390 lines
19 KiB
Diff
Raw Normal View History

2018-09-05 00:23:45 +00:00
--- a/net/minecraft/client/Minecraft.java
+++ b/net/minecraft/client/Minecraft.java
2019-05-23 23:02:15 +00:00
@@ -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;
2019-05-23 23:02:15 +00:00
@@ -333,7 +334,7 @@
supplier = p_213262_2_;
}
2019-05-23 23:02:15 +00:00
- 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));
2019-05-23 23:02:15 +00:00
@@ -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;
@@ -442,7 +442,6 @@
this.field_195558_d.func_216526_a(this.field_71474_y.field_74350_i);
this.field_71417_B = new MouseHelper(this);
- this.field_71417_B.func_198029_a(this.field_195558_d.func_198092_i());
this.field_195559_v = new KeyboardListener(this);
this.field_195559_v.func_197968_a(this.field_195558_d.func_198092_i());
GLX.init();
@@ -451,6 +450,7 @@
2019-05-23 23:02:15 +00:00
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);
2019-05-23 23:02:15 +00:00
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());
@@ -516,12 +516,14 @@
this.field_110451_am.func_219534_a(this.field_193995_ae);
GlStateManager.viewport(0, 0, this.field_195558_d.func_198109_k(), this.field_195558_d.func_198091_l());
this.field_71452_i = new ParticleManager(this.field_71441_e, this.field_71446_o);
+ net.minecraftforge.fml.ModLoader.get().postEvent(new net.minecraftforge.client.event.ParticleFactoryRegisterEvent());
this.field_110451_am.func_219534_a(this.field_71452_i);
this.field_213272_aL = new PaintingSpriteUploader(this.field_71446_o);
2019-05-23 23:02:15 +00:00
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_71417_B.func_198029_a(this.field_195558_d.func_198092_i()); //Forge: Moved below ingameGUI setting to prevent NPEs in handeler.
this.field_184132_p = new DebugRenderer(this);
2019-05-23 23:02:15 +00:00
GLX.setGlfwErrorCallback(this::func_195545_a);
if (this.field_71474_y.field_74353_u && !this.field_195558_d.func_198113_j()) {
@@ -543,7 +545,7 @@
if (SharedConstants.field_206244_b) {
this.func_213256_aB();
}
-
+ net.minecraftforge.fml.client.ClientModLoader.complete();
}, false));
}
@@ -558,7 +560,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();
@@ -647,7 +649,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);
@@ -662,6 +664,7 @@
return this.field_71474_y.field_211842_aO;
}
+ @Deprecated // Forge: Use selective refreshResources method in FMLClientHandler
2019-05-23 23:02:15 +00:00
public CompletableFuture<Void> func_213237_g() {
if (this.field_213276_aV != null) {
return this.field_213276_aV;
@@ -741,16 +744,20 @@
}
2019-05-23 23:02:15 +00:00
public void func_147108_a(@Nullable Screen p_147108_1_) {
- if (this.field_71462_r != null) {
2019-05-23 23:02:15 +00:00
- this.field_71462_r.removed();
- }
-
if (p_147108_1_ == null && this.field_71441_e == null) {
2019-05-23 23:02:15 +00:00
p_147108_1_ = new MainMenuScreen();
} else if (p_147108_1_ == null && this.field_71439_g.func_110143_aJ() <= 0.0F) {
2019-05-23 23:02:15 +00:00
p_147108_1_ = new DeathScreen((ITextComponent)null, this.field_71441_e.func_72912_H().func_76093_s());
}
2019-05-23 23:02:15 +00:00
+ 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)
2019-05-23 23:02:15 +00:00
+ old.removed();
+
2019-05-23 23:02:15 +00:00
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);
@@ -875,11 +882,13 @@
2019-05-23 23:02:15 +00:00
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);
2019-05-23 23:02:15 +00:00
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_);
2019-05-23 23:02:15 +00:00
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);
}
2019-05-23 23:02:15 +00:00
this.field_71424_I.func_219897_b();
@@ -1147,10 +1156,10 @@
2019-05-23 23:02:15 +00:00
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();
2019-05-23 23:02:15 +00:00
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);
}
}
@@ -1177,7 +1186,7 @@
case BLOCK:
2019-05-23 23:02:15 +00:00
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()) {
2019-05-23 23:02:15 +00:00
+ 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;
}
@@ -1187,6 +1196,7 @@
}
this.field_71439_g.func_184821_cY();
+ net.minecraftforge.common.ForgeHooks.onEmptyLeftClick(this.field_71439_g);
}
2019-05-23 23:02:15 +00:00
this.field_71439_g.func_184609_a(Hand.MAIN_HAND);
@@ -1236,6 +1246,9 @@
}
}
2019-05-23 23:02:15 +00:00
+ 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);
+
2019-05-23 23:02:15 +00:00
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;
@@ -1255,6 +1268,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();
@@ -1373,6 +1388,8 @@
2019-05-23 23:02:15 +00:00
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() {
@@ -1527,6 +1544,12 @@
2019-05-23 23:02:15 +00:00
this.func_147108_a(worldloadprogressscreen);
2019-05-23 23:02:15 +00:00
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;
2019-05-23 23:02:15 +00:00
+ } 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);
@@ -1547,11 +1570,17 @@
2019-05-23 23:02:15 +00:00
networkmanager.func_150719_a(new ClientLoginNetHandler(networkmanager, this, (Screen)null, (p_213261_0_) -> {
2018-09-05 00:23:45 +00:00
}));
2019-05-23 23:02:15 +00:00
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());
+ }
2019-05-23 23:02:15 +00:00
+ networkmanager.func_179290_a(new CLoginStartPacket(gameProfile));
this.field_71453_ak = networkmanager;
}
2019-05-23 23:02:15 +00:00
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));
2019-05-23 23:02:15 +00:00
WorkingScreen workingscreen = new WorkingScreen();
workingscreen.func_200210_a(new TranslationTextComponent("connect.joining"));
this.func_213241_c(workingscreen);
@@ -1583,10 +1612,12 @@
IntegratedServer integratedserver = this.field_71437_Z;
this.field_71437_Z = null;
this.field_71460_t.func_190564_k();
+ net.minecraftforge.fml.client.ClientHooks.firePlayerLogout(this.field_71442_b, this.field_71439_g);
this.field_71442_b = null;
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);
@@ -1624,6 +1655,7 @@
}
2019-05-23 23:02:15 +00:00
TileEntityRendererDispatcher.field_147556_a.func_147543_a(p_213257_1_);
+ net.minecraftforge.client.MinecraftForgeClient.clearRenderCache();
2019-05-23 23:02:15 +00:00
}
public final boolean func_71355_q() {
@@ -1649,112 +1681,8 @@
private void func_147112_ai() {
2019-05-23 23:02:15 +00:00
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;
2019-05-23 23:02:15 +00:00
- RayTraceResult.Type raytraceresult$type = this.field_71476_x.func_216346_c();
- ItemStack itemstack;
2019-05-23 23:02:15 +00:00
- 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;
- }
-
2019-05-23 23:02:15 +00:00
- itemstack = block.func_185473_a(this.field_71441_e, blockpos, blockstate);
- if (itemstack.func_190926_b()) {
- return;
- }
-
2019-05-23 23:02:15 +00:00
- if (flag && Screen.hasControlDown() && block.func_149716_u()) {
- tileentity = this.field_71441_e.func_175625_s(blockpos);
- }
- } else {
2019-05-23 23:02:15 +00:00
- if (raytraceresult$type != RayTraceResult.Type.ENTITY || !flag) {
- return;
- }
-
2019-05-23 23:02:15 +00:00
- Entity entity = ((EntityRayTraceResult)this.field_71476_x).func_216348_a();
- if (entity instanceof PaintingEntity) {
- itemstack = new ItemStack(Items.field_151159_an);
2019-05-23 23:02:15 +00:00
- } else if (entity instanceof LeashKnotEntity) {
- itemstack = new ItemStack(Items.field_151058_ca);
2019-05-23 23:02:15 +00:00
- } 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();
- }
2019-05-23 23:02:15 +00:00
- } else if (entity instanceof AbstractMinecartEntity) {
- AbstractMinecartEntity abstractminecartentity = (AbstractMinecartEntity)entity;
- Item item;
2019-05-23 23:02:15 +00:00
- 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);
2019-05-23 23:02:15 +00:00
- } 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);
2019-05-23 23:02:15 +00:00
- } else if (entity instanceof EnderCrystalEntity) {
- itemstack = new ItemStack(Items.field_185158_cP);
- } else {
2019-05-23 23:02:15 +00:00
- SpawnEggItem spawneggitem = SpawnEggItem.func_200889_b(entity.func_200600_R());
- if (spawneggitem == null) {
- return;
- }
-
2019-05-23 23:02:15 +00:00
- itemstack = new ItemStack(spawneggitem);
- }
- }
-
- if (itemstack.func_190926_b()) {
- String s = "";
2019-05-23 23:02:15 +00:00
- 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();
- }
-
2019-05-23 23:02:15 +00:00
- field_147123_G.warn("Picking on: [{}] {} gave null item", raytraceresult$type, s);
- } else {
2019-05-23 23:02:15 +00:00
- PlayerInventory playerinventory = this.field_71439_g.field_71071_by;
- if (tileentity != null) {
- this.func_184119_a(itemstack, tileentity);
- }
-
2019-05-23 23:02:15 +00:00
- int i = playerinventory.func_184429_b(itemstack);
- if (flag) {
2019-05-23 23:02:15 +00:00
- 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) {
2019-05-23 23:02:15 +00:00
- 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
}
}
@@ -1826,6 +1754,7 @@
return field_71432_P;
}
+ @Deprecated // Forge: Use selective scheduleResourceRefresh method in FMLClientHandler
2019-05-23 23:02:15 +00:00
public CompletableFuture<Void> func_213245_w() {
return this.func_213169_a(this::func_213237_g).thenCompose((p_213240_0_) -> {
return p_213240_0_;
@@ -1972,6 +1901,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;
2019-05-23 23:02:15 +00:00
if (this.field_71462_r instanceof WinGameScreen) {
return MusicTicker.MusicType.CREDITS;
} else if (this.field_71439_g == null) {
@@ -2128,4 +2059,12 @@
2019-05-23 23:02:15 +00:00
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;
+ }
}