Skip to content

Instantly share code, notes, and snippets.

@Lothrazar
Created March 23, 2020 02:21
Show Gist options
  • Save Lothrazar/85b432875c6d05d81d649da24940bce4 to your computer and use it in GitHub Desktop.
Save Lothrazar/85b432875c6d05d81d649da24940bce4 to your computer and use it in GitHub Desktop.
button death screen minecraft
@SubscribeEvent
public void onRenderDeathScreen(InitGuiEvent e) {
if (e.getGui() instanceof DeathScreen) {
DeathScreen screen = (DeathScreen) e.getGui();
//
try {
Method m = ObfuscationReflectionHelper.findMethod(Screen.class, "addButton", Widget.class);
m.setAccessible(true);
Button b = new Button(screen.width / 2 - 100, screen.height / 4 + 96 + 24, 200, 20, "hello twitter", (thing) -> {
// this to continue death/respawn cycle as normal
// this.minecraft.player.respawnPlayer();
ClientPlayerEntity player = screen.getMinecraft().player;
BlockPos oldPos = player.getPosition();
GameRuleMod.LOGGER.info("hello twitter " + oldPos);
screen.getMinecraft().displayGuiScreen((Screen) null);
});
b.active = false;
m.invoke(screen, b);
}
catch (Exception exc) {
//go
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment