2021-03-18 22:12:01 +00:00
|
|
|
package net.shadowfacts.phycon.plugin.mousewheelie.mixin;
|
|
|
|
|
|
|
|
import de.siphalor.mousewheelie.client.util.ScrollAction;
|
|
|
|
import de.siphalor.mousewheelie.client.util.accessors.IContainerScreen;
|
|
|
|
import de.siphalor.mousewheelie.client.util.accessors.ISpecialScrollableScreen;
|
|
|
|
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
|
|
|
import net.minecraft.entity.player.PlayerInventory;
|
|
|
|
import net.minecraft.screen.slot.Slot;
|
|
|
|
import net.minecraft.text.Text;
|
2021-03-27 14:22:18 +00:00
|
|
|
import net.shadowfacts.phycon.block.terminal.AbstractTerminalScreen;
|
|
|
|
import net.shadowfacts.phycon.block.terminal.AbstractTerminalScreenHandler;
|
2021-03-18 22:12:01 +00:00
|
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author shadowfacts
|
|
|
|
*/
|
2021-03-27 14:22:18 +00:00
|
|
|
@Mixin(AbstractTerminalScreen.class)
|
|
|
|
public abstract class MixinTerminalScreen extends HandledScreen<AbstractTerminalScreenHandler> implements ISpecialScrollableScreen, IContainerScreen {
|
2021-03-18 22:12:01 +00:00
|
|
|
|
2021-03-27 14:22:18 +00:00
|
|
|
private MixinTerminalScreen(AbstractTerminalScreenHandler screenHandler, PlayerInventory playerInventory, Text text) {
|
2021-03-18 22:12:01 +00:00
|
|
|
super(screenHandler, playerInventory, text);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ScrollAction mouseWheelie_onMouseScrolledSpecial(double mouseX, double mouseY, double scrollAmount) {
|
|
|
|
Slot slot = mouseWheelie_getSlotAt(mouseX, mouseY);
|
|
|
|
if (slot == null) {
|
|
|
|
return ScrollAction.PASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (slot.id < handler.getBufferSlotsEnd()) {
|
|
|
|
// scrolling in the network inventory is never allowed
|
|
|
|
// scrolling out of the buffer is theoretically possible, but there isn't a straightforward way
|
|
|
|
// of telling the server not to mark the buffer slot as TO_NETWORK after mouse wheelie's song and dance
|
|
|
|
return ScrollAction.ABORT;
|
|
|
|
} else {
|
|
|
|
return ScrollAction.PASS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|