-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retain a reference to the player through the inventory window
- Loading branch information
Showing
7 changed files
with
68 additions
and
17 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
8 changes: 8 additions & 0 deletions
8
src/main/java/uk/protonull/civ/chesttracker/mixing/InventoryWindow.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,8 @@ | ||
package uk.protonull.civ.chesttracker.mixing; | ||
|
||
import net.minecraft.client.player.LocalPlayer; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public interface InventoryWindow { | ||
@NotNull LocalPlayer civchesttracker$getPlayer(); | ||
} |
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
37 changes: 37 additions & 0 deletions
37
...va/uk/protonull/civ/chesttracker/mixins/retention/RetainPlayerOnInventoryWindowMixin.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,37 @@ | ||
package uk.protonull.civ.chesttracker.mixins.retention; | ||
|
||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; | ||
import net.minecraft.client.player.LocalPlayer; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.entity.player.Inventory; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import uk.protonull.civ.chesttracker.mixing.InventoryWindow; | ||
|
||
@Mixin(AbstractContainerScreen.class) | ||
public abstract class RetainPlayerOnInventoryWindowMixin implements InventoryWindow { | ||
@Unique | ||
private LocalPlayer player; | ||
|
||
@Redirect( | ||
method = "<init>", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/world/entity/player/Inventory;getDisplayName()Lnet/minecraft/network/chat/Component;" | ||
) | ||
) | ||
protected @NotNull Component civchesttracker$interceptPlayerInstance( | ||
final @NotNull Inventory playerInventory | ||
) { | ||
this.player = (LocalPlayer) playerInventory.player; | ||
return playerInventory.getDisplayName(); | ||
} | ||
|
||
@Override | ||
public @NotNull LocalPlayer civchesttracker$getPlayer() { | ||
return this.player; | ||
} | ||
} |
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