Skip to content

Commit

Permalink
add blacklist for appeng ghost item compact (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
GlodBlock authored Oct 17, 2022
1 parent 939dcfc commit c5bb06f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
12 changes: 12 additions & 0 deletions src/main/scala/net/bdew/neiaddons/appeng/AddonAppeng.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class AddonAppeng extends BaseAddon {
public static AddonAppeng instance;

public static final String setWorkbenchCommand = "SetAE2FakeSlot";
public static String[] blackListGuiName;

public static Class<? extends GuiContainer> clsBaseGui;
public static Class<? extends Container> clsBaseContainer;
Expand All @@ -60,6 +61,17 @@ public void preInit(FMLPreInitializationEvent ev) {
@Override
public void init(Side side) throws Exception {
try {
blackListGuiName = NEIAddons.config
.get(
getName(),
"Blacklist Gui Class Name",
new String[] {
"com.glodblock.github.client.gui.GuiFluidPatternTerminal",
"com.glodblock.github.client.gui.GuiFluidPatternTerminalEx"
},
"These Gui won't have the NEI drag item handler from NEI addon.")
.getStringList();

clsBaseContainer = Utils.getAndCheckClass("appeng.container.AEBaseContainer", Container.class);
clsSlotFake = Utils.getAndCheckClass("appeng.container.slot.SlotFake", Slot.class);
mSlotFakeIsEnabled = clsSlotFake.getMethod("isEnabled");
Expand Down
16 changes: 12 additions & 4 deletions src/main/scala/net/bdew/neiaddons/appeng/AppEngGuiHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
public class AppEngGuiHandler extends INEIGuiAdapter {
@Override
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
if (AddonAppeng.clsBaseGui.isInstance(gui)) {
if (AddonAppeng.clsBaseGui.isInstance(gui) && !checkBlacklist(gui)) {
final Slot currentSlot = getSlotAtPosition(gui, mouseX, mouseY);

if (currentSlot != null
&& AddonAppeng.clsSlotFake.isInstance(currentSlot)
&& SlotHelper.isSlotEnabled(currentSlot)) {
if (AddonAppeng.clsSlotFake.isInstance(currentSlot) && SlotHelper.isSlotEnabled(currentSlot)) {

if (ClientHandler.enabledCommands.contains(AddonAppeng.setWorkbenchCommand)) {
final ItemStack stack = draggedStack.copy();
Expand Down Expand Up @@ -59,6 +57,16 @@ public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemSta
return super.handleDragNDrop(gui, mouseX, mouseY, draggedStack, button);
}

private boolean checkBlacklist(GuiContainer gui) {
String name = gui.getClass().getName();
for (String blacklist : AddonAppeng.blackListGuiName) {
if (blacklist.equals(name)) {
return true;
}
}
return false;
}

private boolean isMouseOverSlot(GuiContainer gui, Slot slot, int mouseX, int mouseY) {
int slotX = slot.xDisplayPosition;
int slotY = slot.yDisplayPosition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public void handle(NBTTagCompound data, EntityPlayerMP player) {
ItemStack stack = ItemStack.loadItemStackFromNBT(data.getCompoundTag("item"));
int slotNum = data.getInteger("slot");
Container cont = player.openContainer;
if ((cont != null) && AddonAppeng.clsBaseContainer.isInstance(cont)) {
if (AddonAppeng.clsBaseContainer.isInstance(cont)) {
Slot slot = cont.getSlot(slotNum);
if ((slot != null) && AddonAppeng.clsSlotFake.isInstance(slot) && SlotHelper.isSlotEnabled(slot)) {
if (AddonAppeng.clsSlotFake.isInstance(slot) && SlotHelper.isSlotEnabled(slot)) {
ItemStack targetStack = slot.getStack();
if (null != targetStack && !data.getBoolean("replace") && stack.isItemEqual(targetStack)) {
stack.stackSize = slot.getStack().stackSize + stack.stackSize;
Expand Down

0 comments on commit c5bb06f

Please sign in to comment.