--- a/net/minecraft/client/Minecraft.java +++ b/net/minecraft/client/Minecraft.java @@ -322,6 +322,7 @@ public Minecraft(GameConfiguration p_i45547_1_) { super("Client"); field_71432_P = this; + net.minecraftforge.client.ForgeHooksClient.invalidateLog4jThreadCache(); this.field_71412_D = p_i45547_1_.field_178744_c.field_178760_a; File file1 = p_i45547_1_.field_178744_c.field_178759_c; this.field_130070_K = p_i45547_1_.field_178744_c.field_178758_b; @@ -336,7 +337,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; @@ -368,6 +368,7 @@ screensize = p_i45547_1_.field_178743_b; } + net.minecraftforge.fml.loading.progress.EarlyProgressVisualization.INSTANCE.join(); Util.field_211180_a = RenderSystem.initBackendSystem(); this.field_195557_T = new VirtualScreen(this); this.field_195558_d = this.field_195557_T.func_217626_a(screensize, this.field_71474_y.field_198019_u, this.func_230149_ax_()); @@ -383,7 +384,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()); RenderSystem.initRenderer(this.field_71474_y.field_209231_W, false); @@ -391,6 +391,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(); this.field_135017_as = new LanguageManager(this.field_71474_y.field_74363_ab); this.field_110451_am.func_219534_a(this.field_135017_as); @@ -434,12 +435,14 @@ this.func_193986_ar(); this.field_110451_am.func_219534_a(this.field_193995_ae); 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); 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.gui.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); RenderSystem.setErrorCallback(this::func_195545_a); if (this.field_71474_y.field_74353_u && !this.field_195558_d.func_198113_j()) { @@ -451,12 +454,11 @@ this.field_195558_d.func_224798_d(this.field_71474_y.field_225307_E); this.field_195558_d.func_227801_c_(); this.func_213226_a(); - if (s != null) { - this.func_147108_a(new ConnectingScreen(new MainMenuScreen(), this, s, i)); - } else { - this.func_147108_a(new MainMenuScreen(true)); - } + //Final needed so we can move into lambda below. + final String autoServerName = s; + final int autoServerPort = i; + ResourceLoadProgressGui.func_212970_a(this); List list = this.field_110448_aq.func_198980_d().stream().map(ResourcePackInfo::func_195796_e).collect(Collectors.toList()); this.func_213268_a(new ResourceLoadProgressGui(this, this.field_110451_am.func_219537_a(Util.func_215072_e(), this, field_223714_G, list), (p_229990_2_) -> { @@ -466,6 +468,14 @@ this.func_213256_aB(); } + if (net.minecraftforge.fml.client.ClientModLoader.completeModLoading()) return; // Do not overwrite the error screen + // FORGE: Move opening initial screen to after startup and events are enabled. + // Also Fixes MC-145102 + if (autoServerName != null) { + this.func_147108_a(new ConnectingScreen(new MainMenuScreen(), this, autoServerName, autoServerPort)); + } else { + this.func_147108_a(new MainMenuScreen(true)); + } }); }, false)); } @@ -579,7 +589,7 @@ return Stream.of(Registry.field_212630_s.func_177774_c(p_213251_0_.func_77973_b())); }); SearchTreeReloadable 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 nonnulllist = NonNullList.func_191196_a(); @@ -667,13 +677,13 @@ Bootstrap.func_179870_a(p_71377_0_.func_71502_e()); if (p_71377_0_.func_71497_f() != null) { Bootstrap.func_179870_a("#@!@# Game crashed! Crash report saved to: #@!@# " + p_71377_0_.func_71497_f()); - System.exit(-1); + net.minecraftforge.fml.server.ServerLifecycleHooks.handleExit(-1); } else if (p_71377_0_.func_147149_a(file2)) { Bootstrap.func_179870_a("#@!@# Game crashed! Crash report saved to: #@!@# " + file2.getAbsolutePath()); - System.exit(-1); + net.minecraftforge.fml.server.ServerLifecycleHooks.handleExit(-1); } else { Bootstrap.func_179870_a("#@?@# Game crashed! Crash report could not be saved. #@?@#"); - System.exit(-2); + net.minecraftforge.fml.server.ServerLifecycleHooks.handleExit(-2); } } @@ -682,6 +692,7 @@ return this.field_71474_y.field_211842_aO; } + @Deprecated // Forge: Use selective refreshResources method in FMLClientHandler public CompletableFuture func_213237_g() { if (this.field_213276_aV != null) { return this.field_213276_aV; @@ -760,10 +771,6 @@ } 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) { @@ -774,6 +781,14 @@ } } + 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); @@ -905,11 +920,13 @@ RenderSystem.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(); @@ -1164,11 +1181,21 @@ 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)) { + net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(0, this.field_71474_y.field_74312_F, Hand.MAIN_HAND); + if (inputEvent.isCanceled()) { + if (inputEvent.shouldSwingHand()) { + this.field_71452_i.addBlockHitEffects(blockpos, blockraytraceresult); + this.field_71439_g.func_184609_a(Hand.MAIN_HAND); + } + return; + } 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); + if (inputEvent.shouldSwingHand()) { + this.field_71452_i.addBlockHitEffects(blockpos, blockraytraceresult); this.field_71439_g.func_184609_a(Hand.MAIN_HAND); + } } } @@ -1187,6 +1214,8 @@ } } else if (!this.field_71439_g.func_184838_M()) { + net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(0, this.field_71474_y.field_74312_F, Hand.MAIN_HAND); + if (!inputEvent.isCanceled()) switch(this.field_71476_x.func_216346_c()) { case ENTITY: this.field_71442_b.func_78764_a(this.field_71439_g, ((EntityRayTraceResult)this.field_71476_x).func_216348_a()); @@ -1194,7 +1223,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_175623_d(blockpos)) { this.field_71442_b.func_180511_b(blockpos, blockraytraceresult.func_216354_b()); break; } @@ -1204,8 +1233,10 @@ } this.field_71439_g.func_184821_cY(); + net.minecraftforge.common.ForgeHooks.onEmptyLeftClick(this.field_71439_g); } + if (inputEvent.shouldSwingHand()) this.field_71439_g.func_184609_a(Hand.MAIN_HAND); } } @@ -1220,6 +1251,11 @@ } for(Hand hand : Hand.values()) { + net.minecraftforge.client.event.InputEvent.ClickInputEvent inputEvent = net.minecraftforge.client.ForgeHooksClient.onClickInput(1, this.field_71474_y.field_74313_G, hand); + if (inputEvent.isCanceled()) { + if (inputEvent.shouldSwingHand()) this.field_71439_g.func_184609_a(hand); + return; + } ItemStack itemstack = this.field_71439_g.func_184586_b(hand); if (this.field_71476_x != null) { switch(this.field_71476_x.func_216346_c()) { @@ -1233,6 +1269,7 @@ if (actionresulttype.func_226246_a_()) { if (actionresulttype.func_226247_b_()) { + if (inputEvent.shouldSwingHand()) this.field_71439_g.func_184609_a(hand); } @@ -1245,6 +1282,7 @@ ActionResultType actionresulttype1 = this.field_71442_b.func_217292_a(this.field_71439_g, this.field_71441_e, hand, blockraytraceresult); if (actionresulttype1.func_226246_a_()) { if (actionresulttype1.func_226247_b_()) { + if (inputEvent.shouldSwingHand()) this.field_71439_g.func_184609_a(hand); if (!itemstack.func_190926_b() && (itemstack.func_190916_E() != i || this.field_71442_b.func_78758_h())) { this.field_71460_t.field_78516_c.func_187460_a(hand); @@ -1260,6 +1298,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()) { ActionResultType actionresulttype2 = this.field_71442_b.func_187101_a(this.field_71439_g, this.field_71441_e, hand); if (actionresulttype2.func_226246_a_()) { @@ -1286,6 +1327,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(); @@ -1403,6 +1446,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() { @@ -1557,6 +1602,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); @@ -1577,11 +1628,17 @@ networkmanager.func_150719_a(new ClientLoginNetHandler(networkmanager, this, (Screen)null, (p_229998_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); @@ -1608,15 +1665,18 @@ if (clientplaynethandler != null) { this.func_213159_be(); clientplaynethandler.func_147296_c(); + net.minecraftforge.client.MinecraftForgeClient.clearRenderCache(); } 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); @@ -1674,112 +1734,9 @@ 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); - } - } - - } + if (!net.minecraftforge.client.ForgeHooksClient.onClickInput(2, this.field_71474_y.field_74322_I, Hand.MAIN_HAND).isCanceled()) + 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 } } @@ -1861,6 +1818,7 @@ return field_71432_P; } + @Deprecated // Forge: Use selective scheduleResourceRefresh method in FMLClientHandler public CompletableFuture func_213245_w() { return this.func_213169_a(this::func_213237_g).thenCompose((p_229993_0_) -> { return p_229993_0_; @@ -1988,6 +1946,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) { @@ -2164,7 +2124,7 @@ supplier = func_228022_c_(supplier); } - return new ClientResourcePackInfo(p_228011_0_, p_228011_1_, supplier, p_228011_3_, p_228011_4_, p_228011_5_); + return new ClientResourcePackInfo(p_228011_0_, p_228011_1_, supplier, p_228011_3_, p_228011_4_, p_228011_5_, p_228011_3_.isHidden()); } private static Supplier func_228021_b_(Supplier p_228021_0_) { @@ -2182,4 +2142,12 @@ public void func_228020_b_(int p_228020_1_) { this.field_175617_aL.func_229355_a_(p_228020_1_); } + + public ItemColors getItemColors() { + return this.field_184128_aI; + } + + public SearchTreeManager getSearchTreeManager() { + return this.field_193995_ae; + } }