mirror of
https://github.com/Wurst-Imperium/Wurst7.git
synced 2024-09-20 01:12:13 +02:00
Merge #792 (AutoRespawn button on death screen) into v7.39
This commit is contained in:
commit
132ab780b2
@ -9,16 +9,23 @@ package net.wurstclient.hacks;
|
||||
|
||||
import net.wurstclient.Category;
|
||||
import net.wurstclient.SearchTags;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.events.DeathListener;
|
||||
import net.wurstclient.hack.Hack;
|
||||
import net.wurstclient.settings.CheckboxSetting;
|
||||
|
||||
@SearchTags({"auto respawn", "AutoRevive", "auto revive"})
|
||||
public final class AutoRespawnHack extends Hack implements DeathListener
|
||||
{
|
||||
private final CheckboxSetting button =
|
||||
new CheckboxSetting("Death screen button", "Shows a button on the death"
|
||||
+ " screen that lets you quickly enable AutoRespawn.", true);
|
||||
|
||||
public AutoRespawnHack()
|
||||
{
|
||||
super("AutoRespawn");
|
||||
setCategory(Category.COMBAT);
|
||||
addSetting(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -39,4 +46,10 @@ public final class AutoRespawnHack extends Hack implements DeathListener
|
||||
MC.player.requestRespawn();
|
||||
MC.setScreen(null);
|
||||
}
|
||||
|
||||
public boolean shouldShowButton()
|
||||
{
|
||||
return WurstClient.INSTANCE.isEnabled() && !isEnabled()
|
||||
&& button.isChecked();
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.client.gui.screen.DeathScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.text.Text;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.event.EventManager;
|
||||
import net.wurstclient.events.DeathListener.DeathEvent;
|
||||
import net.wurstclient.hacks.AutoRespawnHack;
|
||||
|
||||
@Mixin(DeathScreen.class)
|
||||
public abstract class DeathScreenMixin extends Screen
|
||||
@ -27,9 +29,28 @@ public abstract class DeathScreenMixin extends Screen
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(at = @At(value = "TAIL"), method = "tick()V")
|
||||
@Inject(at = @At("TAIL"), method = "tick()V")
|
||||
private void onTick(CallbackInfo ci)
|
||||
{
|
||||
EventManager.fire(DeathEvent.INSTANCE);
|
||||
}
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "init()V")
|
||||
private void onInit(CallbackInfo ci)
|
||||
{
|
||||
AutoRespawnHack autoRespawn =
|
||||
WurstClient.INSTANCE.getHax().autoRespawnHack;
|
||||
|
||||
if(!autoRespawn.shouldShowButton())
|
||||
return;
|
||||
|
||||
int backButtonX = width / 2 - 100;
|
||||
int backButtonY = height / 4;
|
||||
|
||||
addDrawableChild(
|
||||
ButtonWidget.builder(Text.literal("AutoRespawn: OFF"), b -> {
|
||||
autoRespawn.setEnabled(true);
|
||||
autoRespawn.onDeath();
|
||||
}).dimensions(backButtonX, backButtonY + 48, 200, 20).build());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user