pattern transfer in termial

This commit is contained in:
GlodBlock committed 2022-05-17 20:25:58 +08:00
1 parent de89555092
commit 3201e54dc3
3 files changed
+43 -5

No files matched your search

@@ -1,5 +1,6 @@
package com.glodblock.github.common.part;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.parts.IPartModel;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.sync.GuiBridge;
@@ -10,7 +11,9 @@ import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform;
import appeng.util.inv.InvOperation;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.GuiType;
import com.glodblock.github.inventory.InventoryHandler;
import net.minecraft.entity.player.EntityPlayer;
@@ -69,6 +72,42 @@ public class PartFluidPatternTerminal extends PartPatternTerminal {
if (slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (!is.isEmpty() && is.getItem() instanceof ItemFluidEncodedPattern) {
final ItemFluidEncodedPattern pattern = (ItemFluidEncodedPattern) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorld() );
if( details != null )
{
this.setCraftingRecipe( details.isCraftable() );
this.setSubstitution( details.canSubstitute() );
for( int x = 0; x < this.getInventoryByName("crafting").getSlots(); x ++ ) {
((AppEngInternalInventory) this.getInventoryByName("crafting")).setStackInSlot(x, ItemStack.EMPTY);
}
for( int x = 0; x < this.getInventoryByName("output").getSlots(); x ++ ) {
((AppEngInternalInventory) this.getInventoryByName("output")).setStackInSlot(x, ItemStack.EMPTY);
}
for( int x = 0; x < this.getInventoryByName("crafting").getSlots() && x < details.getInputs().length; x++ )
{
final IAEItemStack item = details.getInputs()[x];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.createItemStack()));
((AppEngInternalInventory) this.getInventoryByName("crafting")).setStackInSlot(x, packet);
}
else ((AppEngInternalInventory) this.getInventoryByName("crafting")).setStackInSlot( x, item == null ? ItemStack.EMPTY : item.createItemStack() );
}
for( int x = 0; x < this.getInventoryByName("output").getSlots() && x < details.getOutputs().length; x++ )
{
final IAEItemStack item = details.getOutputs()[x];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.createItemStack()));
((AppEngInternalInventory) this.getInventoryByName("output")).setStackInSlot(x, packet);
}
else ((AppEngInternalInventory) this.getInventoryByName("output")).setStackInSlot( x, item == null ? ItemStack.EMPTY : item.createItemStack() );
}
}
this.getHost().markForSave();
return;
}
}
@@ -210,14 +210,13 @@ public class TileFluidDiscretizer extends AENetworkTile implements ICellContaine
List<IAEItemStack> mappedChanges = new ArrayList<>();
for (IAEFluidStack fluidStack : change) {
boolean isNg = false;
System.out.print(fluidStack + "\n");
if (fluidStack.getStackSize() < 0) {
isNg = true;
fluidStack.setStackSize( - fluidStack.getStackSize());
fluidStack.setStackSize( - fluidStack.getStackSize() );
}
IAEItemStack itemStack = ItemFluidDrop.newAeStack(fluidStack);
if (itemStack != null) {
if (isNg) itemStack.setStackSize( - itemStack.getStackSize());
if (isNg) itemStack.setStackSize( - itemStack.getStackSize() );
mappedChanges.add(itemStack);
}
}