-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
- Loading branch information
1 parent
25b6593
commit 273ec4a
Showing
9 changed files
with
68 additions
and
18 deletions.
There are no files selected for viewing
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
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
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
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
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
26 changes: 26 additions & 0 deletions
26
src/main/java/ru/octol1ttle/flightassistant/mixin/InGameHudMixin.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,26 @@ | ||
package ru.octol1ttle.flightassistant.mixin; | ||
|
||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.LayeredDrawer; | ||
import net.minecraft.client.gui.hud.InGameHud; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import ru.octol1ttle.flightassistant.util.events.AlternateHudRendererCallback; | ||
|
||
@Mixin(InGameHud.class) | ||
public class InGameHudMixin { | ||
@Shadow | ||
@Final | ||
private LayeredDrawer layeredDrawer; | ||
|
||
// modifications made: changed injection point | ||
@Inject(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/LayeredDrawer;addLayer(Lnet/minecraft/client/gui/LayeredDrawer$Layer;)Lnet/minecraft/client/gui/LayeredDrawer;", ordinal = 3)) | ||
public void render(MinecraftClient client, CallbackInfo ci) { | ||
// modifications made: changed from FAPIs interface to my interface | ||
this.layeredDrawer.addLayer((context, tickCounter) -> AlternateHudRendererCallback.EVENT.invoker().onHudRender(context, tickCounter.getTickDelta(true))); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/ru/octol1ttle/flightassistant/util/events/AlternateHudRendererCallback.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,22 @@ | ||
package ru.octol1ttle.flightassistant.util.events; | ||
|
||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.minecraft.client.gui.DrawContext; | ||
|
||
public interface AlternateHudRendererCallback { | ||
// modifications mode: change HudRendererCallback -> AlternateHudRendererCallback | ||
Event<AlternateHudRendererCallback> EVENT = EventFactory.createArrayBacked(AlternateHudRendererCallback.class, (listeners) -> (matrixStack, delta) -> { | ||
for (AlternateHudRendererCallback event : listeners) { | ||
event.onHudRender(matrixStack, delta); | ||
} | ||
}); | ||
|
||
/** | ||
* Called after rendering the whole hud, which is displayed in game, in a world. | ||
* | ||
* @param drawContext the {@link DrawContext} instance | ||
* @param tickDelta Progress for linearly interpolating between the previous and current game state | ||
*/ | ||
void onHudRender(DrawContext drawContext, float tickDelta); | ||
} |
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
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