Use callback-style events for crosshair and hotbar render events
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
//#if MC>=11400
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import com.replaymod.replay.events.RenderHotbarCallback;
|
||||
import com.replaymod.replay.events.RenderSpectatorCrosshairCallback;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(InGameHud.class)
|
||||
@@ -17,5 +19,13 @@ public class MixinInGameHud {
|
||||
ci.setReturnValue(state);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderHotbar", at = @At("HEAD"), cancellable = true)
|
||||
private void shouldRenderHotbar(CallbackInfo ci) {
|
||||
Boolean state = RenderHotbarCallback.EVENT.invoker().shouldRenderHotbar();
|
||||
if (state == Boolean.FALSE) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
Reference in New Issue
Block a user