1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package me.shedaniel.rei.mixin;
import me.shedaniel.rei.listeners.IMixinTabGetter;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
import net.minecraft.client.renderer.InventoryEffectRenderer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemGroup;
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.CallbackInfoReturnable;
@Mixin(GuiContainerCreative.class)
public abstract class MixinGuiContainerCreative extends InventoryEffectRenderer implements IMixinTabGetter {
@Shadow
private static int selectedTabIndex;
@Shadow
private boolean field_195377_F;
public MixinGuiContainerCreative(Container inventorySlotsIn) {
super(inventorySlotsIn);
}
@Shadow
protected abstract boolean needsScrollBars();
@Override
public int getSelectedTab() {
return selectedTabIndex;
}
@Inject(method = "mouseScrolled", at = @At("HEAD"), cancellable = true)
public void mouseScrolled(double amount, CallbackInfoReturnable<Boolean> ci) {
if (!needsScrollBars())
if (super.mouseScrolled(amount)) {
ci.setReturnValue(true);
ci.cancel();
}
}
@Inject(method = "keyPressed", at = @At("HEAD"), cancellable = true)
public void keyPressed(int int_1, int int_2, int int_3, CallbackInfoReturnable<Boolean> ci) {
if (selectedTabIndex == ItemGroup.INVENTORY.getIndex())
if (super.keyPressed(int_1, int_2, int_3)) {
ci.setReturnValue(true);
ci.cancel();
}
}
@Inject(method = "charTyped", at = @At("HEAD"), cancellable = true)
public void charTyped(char char_1, int int_1, CallbackInfoReturnable<Boolean> ci) {
if (!this.field_195377_F && selectedTabIndex == ItemGroup.INVENTORY.getIndex())
if (super.charTyped(char_1, int_1)) {
ci.setReturnValue(true);
ci.cancel();
}
}
}
|