-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make world load faster, enable GUIs in nether portal
- Loading branch information
Showing
4 changed files
with
77 additions
and
6 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/main/java/org/dimdev/vanillafix/mixins/client/MixinEntityPlayerSP.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.dimdev.vanillafix.mixins.client; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.entity.EntityPlayerSP; | ||
import net.minecraft.client.gui.GuiScreen; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@SuppressWarnings({"unused", "NonConstantFieldWithUpperCaseName", "RedundantThrows"}) // Shadow | ||
@Mixin(EntityPlayerSP.class) | ||
public class MixinEntityPlayerSP { | ||
@Redirect(method = "onLivingUpdate", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;currentScreen:Lnet/minecraft/client/gui/GuiScreen;", ordinal = 0)) | ||
public GuiScreen getCurrentScreen(Minecraft mc) { | ||
return null; // Enable GUIs in portals | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/org/dimdev/vanillafix/mixins/client/MixinNetHandlerPlayClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.dimdev.vanillafix.mixins.client; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.multiplayer.WorldClient; | ||
import net.minecraft.client.network.NetHandlerPlayClient; | ||
import net.minecraft.network.PacketThreadUtil; | ||
import net.minecraft.network.play.INetHandlerPlayClient; | ||
import net.minecraft.network.play.server.SPacketRespawn; | ||
import net.minecraft.scoreboard.Scoreboard; | ||
import net.minecraft.world.WorldSettings; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
@SuppressWarnings({"unused", "NonConstantFieldWithUpperCaseName"}) // Shadow | ||
@Mixin(NetHandlerPlayClient.class) | ||
public abstract class MixinNetHandlerPlayClient implements INetHandlerPlayClient { | ||
@Shadow private boolean doneLoadingTerrain; | ||
@Shadow private WorldClient world; | ||
@Shadow private Minecraft client; | ||
|
||
@Overwrite | ||
@Override | ||
public void handleRespawn(SPacketRespawn packetIn) { | ||
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, client); | ||
|
||
if (packetIn.getDimensionID() != client.player.dimension) { | ||
doneLoadingTerrain = false; | ||
client.displayGuiScreen(null); | ||
|
||
Scoreboard scoreboard = world.getScoreboard(); | ||
world = new WorldClient((NetHandlerPlayClient) (Object) this, new WorldSettings(0L, packetIn.getGameType(), false, client.world.getWorldInfo().isHardcoreModeEnabled(), packetIn.getWorldType()), packetIn.getDimensionID(), packetIn.getDifficulty(), client.mcProfiler); | ||
world.setWorldScoreboard(scoreboard); | ||
client.loadWorld(world); | ||
client.player.dimension = packetIn.getDimensionID(); | ||
} | ||
|
||
client.setDimensionAndSpawnPlayer(packetIn.getDimensionID()); | ||
client.playerController.setGameType(packetIn.getGameType()); | ||
} | ||
|
||
// @Redirect(method = "handleRespawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;displayGuiScreen(Lnet/minecraft/client/gui/GuiScreen;)V", ordinal = 0)) | ||
// public void patchDisplayGuiScreen(Minecraft minecraft, GuiScreen screen) {} | ||
// | ||
// @Inject(method = "handleRespawn", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/NetHandlerPlayClient;doneLoadingTerrain:Z", ordinal = 0)) | ||
// public void setDoneLoadingTerrain(boolean value) { | ||
// client.displayGuiScreen(null); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters