-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68fe9aa
commit 80b6a36
Showing
10 changed files
with
158 additions
and
10 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
src/main/java/dev/adventurecraft/awakening/extension/container/ExPlayerContainer.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 dev.adventurecraft.awakening.extension.container; | ||
|
||
public interface ExPlayerContainer { | ||
|
||
boolean getAllowsCrafting(); | ||
|
||
void setAllowsCrafting(boolean value); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/dev/adventurecraft/awakening/extension/container/slot/ExSlot.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 dev.adventurecraft.awakening.extension.container.slot; | ||
|
||
public interface ExSlot { | ||
|
||
boolean getEnabled(); | ||
|
||
void setEnabled(boolean value); | ||
} |
26 changes: 26 additions & 0 deletions
26
.../dev/adventurecraft/awakening/mixin/client/gui/screen/container/MixinContainerScreen.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 dev.adventurecraft.awakening.mixin.client.gui.screen.container; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import dev.adventurecraft.awakening.extension.container.slot.ExSlot; | ||
import dev.adventurecraft.awakening.mixin.client.gui.screen.MixinScreen; | ||
import net.minecraft.client.gui.screen.container.ContainerScreen; | ||
import net.minecraft.container.slot.Slot; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(ContainerScreen.class) | ||
public abstract class MixinContainerScreen extends MixinScreen { | ||
|
||
@WrapOperation( | ||
method = "render", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/client/gui/screen/container/ContainerScreen;isMouseOverSlot(Lnet/minecraft/container/slot/Slot;II)Z")) | ||
private boolean wrapSlotHover(ContainerScreen instance, Slot slot, int x, int y, Operation<Boolean> original) { | ||
if (((ExSlot) slot).getEnabled()) { | ||
return original.call(instance, slot, x, y); | ||
} | ||
return false; | ||
} | ||
} |
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
19 changes: 19 additions & 0 deletions
19
src/main/java/dev/adventurecraft/awakening/mixin/container/MixinPlayerContainerSlot.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,19 @@ | ||
package dev.adventurecraft.awakening.mixin.container; | ||
|
||
import dev.adventurecraft.awakening.mixin.container.slot.MixinSlot; | ||
import net.minecraft.item.ItemStack; | ||
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.CallbackInfoReturnable; | ||
|
||
@Mixin(targets = "net.minecraft.container.PlayerContainer$1") | ||
public abstract class MixinPlayerContainerSlot extends MixinSlot { | ||
|
||
@Inject(method = "canInsert", at = @At("HEAD"), cancellable = true) | ||
private void cancelCanInsert(ItemStack item, CallbackInfoReturnable<Boolean> cir) { | ||
if (!this.getEnabled()) { | ||
cir.setReturnValue(false); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/dev/adventurecraft/awakening/mixin/container/slot/MixinSlot.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,32 @@ | ||
package dev.adventurecraft.awakening.mixin.container.slot; | ||
|
||
import dev.adventurecraft.awakening.extension.container.slot.ExSlot; | ||
import net.minecraft.container.slot.Slot; | ||
import net.minecraft.item.ItemStack; | ||
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.CallbackInfoReturnable; | ||
|
||
@Mixin(Slot.class) | ||
public abstract class MixinSlot implements ExSlot { | ||
|
||
private boolean enabled = true; | ||
|
||
@Override | ||
public boolean getEnabled() { | ||
return this.enabled; | ||
} | ||
|
||
@Override | ||
public void setEnabled(boolean value) { | ||
this.enabled = value; | ||
} | ||
|
||
@Inject(method = "canInsert", at = @At("HEAD"), cancellable = true) | ||
private void cancelCanInsert(ItemStack item, CallbackInfoReturnable<Boolean> cir) { | ||
if (!this.enabled) { | ||
cir.setReturnValue(false); | ||
} | ||
} | ||
} |
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