Skip to content

Commit

Permalink
Fixed issue with inserting non-phial items into Essentia Terminal
Browse files Browse the repository at this point in the history
Fixes #366
  • Loading branch information
BrockWS committed Mar 12, 2019
1 parent 1eb5263 commit 9847dad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;

import net.minecraftforge.items.wrapper.PlayerMainInvWrapper;

Expand All @@ -21,6 +22,7 @@
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.aspects.IEssentiaContainerItem;

import thaumicenergistics.api.ThEApi;
import thaumicenergistics.api.storage.IAEEssentiaStack;
import thaumicenergistics.api.storage.IEssentiaStorageChannel;
import thaumicenergistics.container.ActionType;
Expand Down Expand Up @@ -61,12 +63,13 @@ public void onAction(EntityPlayerMP player, PacketUIAction packet) {
if (packet.action == ActionType.FILL_ESSENTIA_ITEM && packet.requestedStack instanceof IAEEssentiaStack) {
IAEEssentiaStack requestedStack = (IAEEssentiaStack) packet.requestedStack;
ItemStack toFill = inv.getItemStack().copy();
if (toFill.isEmpty() || !(toFill.getItem() instanceof IEssentiaContainerItem))
ResourceLocation registryName = toFill.getItem().getRegistryName();
if (toFill.isEmpty() || !(toFill.getItem() instanceof IEssentiaContainerItem) || registryName == null)
return;
toFill.setCount(1);

IEssentiaContainerItem containerItem = (IEssentiaContainerItem) toFill.getItem();
int max = TCUtil.getMaxStorable(containerItem);
int max = ThEApi.instance().config().essentiaContainerCapacity().getOrDefault(registryName.toString(), 0);
if (max < 1 || (containerItem.getAspects(toFill) != null && containerItem.getAspects(toFill).size() > 0))
return;

Expand Down Expand Up @@ -94,11 +97,12 @@ public void onAction(EntityPlayerMP player, PacketUIAction packet) {
this.monitor.extractItems(stack, Actionable.MODULATE, this.part.source);
} else if (packet.action == ActionType.EMPTY_ESSENTIA_ITEM) {
ItemStack toEmpty = inv.getItemStack().copy();
if (toEmpty.isEmpty() || !(toEmpty.getItem() instanceof IEssentiaContainerItem))
ResourceLocation registryName = toEmpty.getItem().getRegistryName();
if (toEmpty.isEmpty() || !(toEmpty.getItem() instanceof IEssentiaContainerItem) || registryName == null)
return;
IEssentiaContainerItem containerItem = (IEssentiaContainerItem) toEmpty.getItem();
AspectList list = containerItem.getAspects(toEmpty);
if (list == null || list.size() < 1)
if (list == null || list.size() < 1 || ThEApi.instance().config().essentiaContainerCapacity().getOrDefault(registryName.toString(), 0) < 1)
return;
AtomicBoolean canInsert = new AtomicBoolean(true);
list.aspects.forEach((aspect, amount) -> {
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/thaumicenergistics/util/TCUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@ public static void drainVis(World world, BlockPos pos, float vis, int radis) {
ThELog.error("Failed to drain enough vis from nearby chunks. Drained {} of {}", drained, vis);
}

@Deprecated
public static int getMaxStorable(IEssentiaContainerItem container) {
switch (container.getClass().getSimpleName()) {
case "ItemPhial":
return 10;
}
return 0;
}

public static Aspect getCrystalAspect(ItemStack stack) {
if (!(stack.getItem() instanceof IEssentiaContainerItem) || stack.getItem() != ItemsTC.crystalEssence)
return null;
Expand Down

0 comments on commit 9847dad

Please sign in to comment.