Fix duplicate onPlayerDeath call b/c mojang is bad, fixes #85

This commit is contained in:
Brady 2018-08-23 19:18:49 -05:00
parent 85c88e669c
commit 4de52cfec2
No known key found for this signature in database
GPG Key ID: 73A788379A197567
3 changed files with 13 additions and 40 deletions

View File

@ -1,39 +0,0 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.launch.mixins;
import baritone.Baritone;
import net.minecraft.client.gui.GuiGameOver;
import net.minecraft.util.text.ITextComponent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/**
* @author Brady
* @since 8/22/2018
*/
@Mixin(GuiGameOver.class)
public class MixinGuiGameOver {
@Inject(method = "<init>", at = @At("RETURN"))
private void onInit(ITextComponent causeOfDeathIn, CallbackInfo ci) {
Baritone.INSTANCE.getGameEventHandler().onPlayerDeath();
}
}

View File

@ -22,6 +22,7 @@ import baritone.event.events.ChunkEvent;
import baritone.event.events.type.EventState;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.network.play.server.SPacketChunkData;
import net.minecraft.network.play.server.SPacketCombatEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@ -66,4 +67,16 @@ public class MixinNetHandlerPlayClient {
)
);
}
@Inject(
method = "handleCombatEvent",
at = @At(
value = "INVOKE",
target = "net/minecraft/client/Minecraft.displayGuiScreen(Lnet/minecraft/client/gui/GuiScreen;)V"
)
)
private void onPlayerDeath(SPacketCombatEvent packetIn, CallbackInfo ci) {
Baritone.INSTANCE.getGameEventHandler().onPlayerDeath();
System.out.println("DIED");
}
}

View File

@ -13,7 +13,6 @@
"MixinEntityRenderer",
"MixinGameSettings",
"MixinGuiContainer",
"MixinGuiGameOver",
"MixinGuiScreen",
"MixinInventoryPlayer",
"MixinKeyBinding",