Skip to content

Commit

Permalink
Make OreDict Storage Buses upgradeable
Browse files Browse the repository at this point in the history
  • Loading branch information
NotMyWing committed May 28, 2024
1 parent 6864f7a commit 68de8fa
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.config.StorageFilter;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.MEGuiTextField;
Expand All @@ -27,7 +26,7 @@
import java.util.regex.Pattern;


public class GuiOreDictStorageBus extends AEBaseGui {
public class GuiOreDictStorageBus extends GuiUpgradeable {
private final ContainerOreDictStorageBus container;
PartOreDicStorageBus part;
private GuiTabButton priority;
Expand All @@ -41,13 +40,11 @@ public GuiOreDictStorageBus(final InventoryPlayer inventoryPlayer, final PartOre
super(new ContainerOreDictStorageBus(inventoryPlayer, te));
this.container = (ContainerOreDictStorageBus) super.inventorySlots;
part = te;
this.ySize = 84;
this.ySize = 170;
}

@Override
public void initGui() {
super.initGui();

protected void addButtons() {
this.searchFieldInputs = new MEGuiTextField(this.fontRenderer, this.guiLeft + 3, this.guiTop + 22, 170, 12);
this.searchFieldInputs.setEnableBackgroundDrawing(false);
this.searchFieldInputs.setMaxStringLength(512);
Expand All @@ -66,7 +63,6 @@ public void initGui() {
} catch (IOException e) {
e.printStackTrace();
}

}

public void fillRegex(String regex) {
Expand Down Expand Up @@ -143,10 +139,13 @@ public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
}

@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture("guis/oredictstoragebus.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, 175, 85);
protected String getBackground() {
return "guis/oredictstoragebus.png";
}

@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
super.drawBG(offsetX, offsetY, mouseX, mouseY);
if (this.searchFieldInputs != null) {
this.searchFieldInputs.drawTextBox();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package appeng.container.implementations;

import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.api.config.StorageFilter;
import appeng.api.config.*;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.parts.misc.PartOreDicStorageBus;
Expand All @@ -18,6 +15,7 @@
import appeng.util.item.OreReference;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.oredict.OreDictionary;

import java.io.IOException;
Expand All @@ -26,7 +24,7 @@
import java.util.Set;


public class ContainerOreDictStorageBus extends AEBaseContainer {
public class ContainerOreDictStorageBus extends ContainerUpgradeable {
private final PartOreDicStorageBus part;

@GuiSync(3)
Expand All @@ -35,6 +33,9 @@ public class ContainerOreDictStorageBus extends AEBaseContainer {
@GuiSync(4)
public StorageFilter storageFilter = StorageFilter.EXTRACTABLE_ONLY;

@GuiSync(7)
public YesNo stickyMode = YesNo.NO;

public ContainerOreDictStorageBus(final InventoryPlayer ip, final PartOreDicStorageBus anchor) {
super(ip, anchor);
this.part = anchor;
Expand All @@ -47,9 +48,15 @@ public void detectAndSendChanges() {
if (Platform.isServer()) {
this.setReadWriteMode((AccessRestriction) part.getConfigManager().getSetting(Settings.ACCESS));
this.setStorageFilter((StorageFilter) part.getConfigManager().getSetting(Settings.STORAGE_FILTER));
this.setStickyMode((YesNo) this.getUpgradeable().getConfigManager().getSetting(Settings.STICKY_MODE));
}

super.detectAndSendChanges();
super.standardDetectAndSendChanges();
}

@Override
protected int getHeight() {
return 170;
}

public void partition() {
Expand Down Expand Up @@ -116,4 +123,29 @@ public StorageFilter getStorageFilter() {
private void setStorageFilter(final StorageFilter storageFilter) {
this.storageFilter = storageFilter;
}

@Override
protected void setupConfig() {
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades");
this.addSlotToContainer((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getInventoryPlayer()))
.setNotDraggable());
}

@Override
public int availableUpgrades() {
return 1;
}

@Override
protected boolean supportCapacity() {
return false;
}

public YesNo getStickyMode() {
return this.stickyMode;
}

private void setStickyMode(final YesNo stickyMode) {
this.stickyMode = stickyMode;
}
}
5 changes: 4 additions & 1 deletion src/main/java/appeng/core/Registration.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
import appeng.core.stats.Stats;
import appeng.core.worlddata.SpatialDimensionManager;
import appeng.fluids.registries.BasicFluidCellGuiHandler;
import appeng.hooks.WrenchClickHook;
import appeng.hooks.TickHandler;
import appeng.hooks.WrenchClickHook;
import appeng.items.materials.ItemMaterial;
import appeng.items.parts.ItemFacade;
import appeng.items.parts.ItemPart;
Expand Down Expand Up @@ -406,6 +406,9 @@ void postInit(final FMLPostInitializationEvent event) {
Upgrades.CAPACITY.registerItem(parts.storageBus(), 5);
Upgrades.STICKY.registerItem(parts.storageBus(), 1);

// OreDict Storage Bus
Upgrades.STICKY.registerItem(parts.oreDictStorageBus(), 1);

// Storage Bus Fluids
Upgrades.INVERTER.registerItem(parts.fluidStorageBus(), 1);
Upgrades.CAPACITY.registerItem(parts.fluidStorageBus(), 5);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/appeng/parts/misc/PartOreDicStorageBus.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public MEInventoryHandler<IAEItemStack> getInternalHandler() {
this.handler.setPriority(this.priority);
this.handler.setPartitionList(this.getPriorityList());
this.handler.setStorageFilter((StorageFilter) this.getConfigManager().getSetting(Settings.STORAGE_FILTER));
this.handler.setSticky(this.getInstalledUpgrades(Upgrades.STICKY) > 0);

if (inv instanceof IBaseMonitor) {
if (((AccessRestriction) ((ConfigManager) this.getConfigManager()).getSetting(Settings.ACCESS)).hasPermission(AccessRestriction.READ)) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 68de8fa

Please sign in to comment.