Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.darkona.adventurebackpack.common.Constants.Source;
import com.darkona.adventurebackpack.config.Keybindings;
import com.darkona.adventurebackpack.init.ModNetwork;
import com.darkona.adventurebackpack.inventory.ContainerAdventure;
import com.darkona.adventurebackpack.inventory.SlotFluid;
import com.darkona.adventurebackpack.network.EquipUnequipBackWearablePacket;
import com.darkona.adventurebackpack.reference.LoadedMods;
import com.darkona.adventurebackpack.util.TConstructTab;
Expand Down Expand Up @@ -68,19 +70,19 @@ protected void keyTyped(char key, int keycode) {

@Override
public void handleMouseInput() {
if (Mouse.getEventDWheel() != 0) {
int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
int marginX = (width - xSize) / 2;
int marginY = (height - ySize) / 2;

if (i > marginX && i < marginX + xSize) {
if (j > marginY && j < marginY + ySize) {
return;
// forbid mouseWheel when mouse over our GUI,
// Shift+Wheel on stacks of fluid containers places them to clients bucket slots, causes desync
}
if (Mouse.getEventDWheel() != 0 && theSlot instanceof SlotFluid) {
return; // fluid slot processing is server-only, scroll would desync
}

// skip fluid slot routing on scroll so containers go to regular inventory client-side
if (Mouse.getEventDWheel() != 0 && inventorySlots instanceof ContainerAdventure) {
((ContainerAdventure) inventorySlots).skipFluidSlots = true;
try {
super.handleMouseInput();
} finally {
((ContainerAdventure) inventorySlots).skipFluidSlots = false;
}
return;
}

super.handleMouseInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public abstract class ContainerAdventure extends Container {
private final int[] fluidsAmount;
private int itemsCount;
private boolean requestedUpdate;
public boolean skipFluidSlots;

protected ContainerAdventure(EntityPlayer player, IInventoryTanks inventory, Source source) {
this.player = player;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private void syncCraftResultToServer() {
protected boolean transferStackToPack(ItemStack stack) {
if (SlotTool.isValidTool(stack)) {
if (!mergeToolSlot(stack)) if (SlotBackpack.isValidItem(stack)) return mergeBackpackInv(stack);
} else if (SlotFluid.isContainer(stack) && !isHoldingSpace()) {
} else if (SlotFluid.isContainer(stack) && !isHoldingSpace() && !skipFluidSlots) {
return transferFluidContainer(stack);
} else if (SlotBackpack.isValidItem(stack)) {
return mergeBackpackInv(stack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void makeSlots(InventoryPlayer invPlayer) {

@Override
public boolean transferStackToPack(ItemStack stack) {
if (SlotFluid.isContainer(stack)) {
if (SlotFluid.isContainer(stack) && !skipFluidSlots) {
FluidTank fuelTank = ((InventoryCopterPack) inventory).getFuelTank();
ItemStack stackOut = getSlot(COPTER_INV_START + 1).getStack();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected boolean detectItemChanges() {

@Override
public boolean transferStackToPack(ItemStack stack) {
if (SlotFluid.isContainer(stack)) {
if (SlotFluid.isContainer(stack) && !skipFluidSlots) {
FluidTank waterTank = ((InventoryCoalJetpack) inventory).getWaterTank();
ItemStack stackOut = getSlot(JETPACK_INV_START + 1).getStack();

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/adventurebackpack_at.cfg
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
protected net.minecraft.inventory.InventoryCrafting field_70466_a # stackList
protected net.minecraft.inventory.InventoryCrafting field_70466_a # stackList
protected net.minecraft.client.gui.inventory.GuiContainer field_147006_u # theSlot
Loading