Skip to content

Commit

Permalink
fix gui slot filter in fluid assembler
Browse files Browse the repository at this point in the history
  • Loading branch information
GlodBlock committed Nov 6, 2023
1 parent b1da434 commit c3be7ca
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies {
deobfCompile 'curse.maven:modular-machinery-270790:2761302' // 1.11.1
deobfCompile 'curse.maven:codechicken-lib-1-8-242818:2779848' //ccl
deobfCompile 'curse.maven:gregtech-ce-unofficial-557242:3784798' // gt
deobfCompile 'curse.maven:ae2-extended-life-570458:4688138' //pae2
deobfCompile 'curse.maven:ae2-extended-life-570458:4812257' //pae2
deobfCompile 'curse.maven:dynamistics-383632:3056455' // dy
compileOnly 'curse.maven:opencomputers-223008:4630537' //oc
runtime 'curse.maven:opencomputers-223008:4630537' //oc
Expand Down
14 changes: 14 additions & 0 deletions src/api/java/yalter/mousetweaks/api/MouseTweaksIgnore.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package yalter.mousetweaks.api;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Put this on your GuiScreen to disable Mouse Tweaks.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface MouseTweaksIgnore {
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
package com.glodblock.github.client.container;

import appeng.api.AEApi;
import appeng.api.config.SecurityPermissions;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.interfaces.IProgressProvider;
import appeng.container.slot.*;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.util.Platform;
import com.glodblock.github.common.item.ItemFluidCraftEncodedPattern;
import com.glodblock.github.common.tile.TileFluidAssembler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;

import javax.annotation.Nonnull;

public class ContainerFluidAssembler extends AEBaseContainer implements IOptionalSlotHost, IProgressProvider {

private final TileFluidAssembler tile;
Expand All @@ -32,12 +39,12 @@ public ContainerFluidAssembler(InventoryPlayer ipl, TileFluidAssembler tile) {
}
for (int i = 0; i < 3; i ++) {
for (int j = 0; j < 3; j ++) {
this.addSlotToContainer(new SlotFake(tile.gridInv, j + i * 3, 29 + j * 18, 16 + i * 18));
this.addSlotToContainer(new FakeDisplaySlot(tile.gridInv, j + i * 3, 29 + j * 18, 16 + i * 18));
}
}
this.addSlotToContainer(new SlotFake(tile.output, 0, 126, 35));
this.addSlotToContainer(new AppEngSlot(tile.upgrade, 0, 134, 61));
this.addSlotToContainer(new AppEngSlot(tile.upgrade, 1, 152, 61));
this.addSlotToContainer(new FakeDisplaySlot(tile.output, 0, 126, 35));
this.addSlotToContainer(new FilterSlot(AEApi.instance().definitions().materials().cardSpeed().maybeStack(1).get(), tile.upgrade, 0, 134, 61));
this.addSlotToContainer(new FilterSlot(AEApi.instance().definitions().materials().cardPatternExpansion().maybeStack(1).get(), tile.upgrade, 1, 152, 61));
bindPlayerInventory(ipl, 0, 167);
}

Expand Down Expand Up @@ -96,5 +103,67 @@ public boolean isItemValid(ItemStack i) {
return i.getItem() instanceof ItemFluidCraftEncodedPattern;
}
}

static class FilterSlot extends AppEngSlot {

final private ItemStack filter;

public FilterSlot(ItemStack filter, IItemHandler i, int slotIndex, int x, int y) {
super(i, slotIndex, x, y);
this.filter = filter;
}

@Override
public boolean isItemValid(@Nonnull ItemStack i) {
if (!this.getContainer().isValidForSlot(this, i)) {
return false;
} else if (i.isEmpty()) {
return false;
} else if (i.getItem() == Items.AIR) {
return false;
} else if (!super.isItemValid(i)) {
return false;
}
return this.filter.isItemEqual(i);
}
}

static class FakeDisplaySlot extends AppEngSlot {
public FakeDisplaySlot(IItemHandler inv, int idx, int x, int y) {
super(inv, idx, x, y);
}

@Nonnull
@Override
public ItemStack onTake(@Nonnull EntityPlayer par1EntityPlayer, @Nonnull ItemStack par2ItemStack) {
return par2ItemStack;
}

@Nonnull
@Override
public ItemStack decrStackSize(int par1) {
return ItemStack.EMPTY;
}

@Override
public boolean isItemValid(@Nonnull ItemStack par1ItemStack) {
return false;
}

@Override
public void putStack(ItemStack is) {
if (!is.isEmpty()) {
is = is.copy();
}

super.putStack(is);
}

@Override
public boolean canTakeStack(EntityPlayer par1EntityPlayer) {
return false;
}
}

}

0 comments on commit c3be7ca

Please sign in to comment.