Started working on crafting infrastructure and C-Cpus
This commit is contained in:
@@ -5,6 +5,7 @@ import java.util.EnumSet;
|
|||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import appeng.block.AEBaseBlock;
|
import appeng.block.AEBaseBlock;
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
|
import appeng.tile.crafting.TileCraftingTile;
|
||||||
|
|
||||||
public class BlockCraftingMonitor extends AEBaseBlock
|
public class BlockCraftingMonitor extends AEBaseBlock
|
||||||
{
|
{
|
||||||
@@ -12,6 +13,7 @@ public class BlockCraftingMonitor extends AEBaseBlock
|
|||||||
public BlockCraftingMonitor() {
|
public BlockCraftingMonitor() {
|
||||||
super( BlockCraftingMonitor.class, Material.iron );
|
super( BlockCraftingMonitor.class, Material.iron );
|
||||||
setfeature( EnumSet.of( AEFeature.Crafting ) );
|
setfeature( EnumSet.of( AEFeature.Crafting ) );
|
||||||
|
setTileEntiy( TileCraftingTile.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.EnumSet;
|
|||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import appeng.block.AEBaseBlock;
|
import appeng.block.AEBaseBlock;
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
|
import appeng.tile.crafting.TileCraftingTile;
|
||||||
|
|
||||||
public class BlockCraftingStorage extends AEBaseBlock
|
public class BlockCraftingStorage extends AEBaseBlock
|
||||||
{
|
{
|
||||||
@@ -12,6 +13,7 @@ public class BlockCraftingStorage extends AEBaseBlock
|
|||||||
public BlockCraftingStorage() {
|
public BlockCraftingStorage() {
|
||||||
super( BlockCraftingStorage.class, Material.iron );
|
super( BlockCraftingStorage.class, Material.iron );
|
||||||
setfeature( EnumSet.of( AEFeature.Crafting ) );
|
setfeature( EnumSet.of( AEFeature.Crafting ) );
|
||||||
|
setTileEntiy( TileCraftingTile.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.EnumSet;
|
|||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import appeng.block.AEBaseBlock;
|
import appeng.block.AEBaseBlock;
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
|
import appeng.tile.crafting.TileCraftingTile;
|
||||||
|
|
||||||
public class BlockCraftingUnit extends AEBaseBlock
|
public class BlockCraftingUnit extends AEBaseBlock
|
||||||
{
|
{
|
||||||
@@ -12,6 +13,7 @@ public class BlockCraftingUnit extends AEBaseBlock
|
|||||||
public BlockCraftingUnit() {
|
public BlockCraftingUnit() {
|
||||||
super( BlockCraftingUnit.class, Material.iron );
|
super( BlockCraftingUnit.class, Material.iron );
|
||||||
setfeature( EnumSet.of( AEFeature.Crafting ) );
|
setfeature( EnumSet.of( AEFeature.Crafting ) );
|
||||||
|
setTileEntiy( TileCraftingTile.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import net.minecraft.world.World;
|
|||||||
import appeng.api.config.RedstoneMode;
|
import appeng.api.config.RedstoneMode;
|
||||||
import appeng.api.config.SecurityPermissions;
|
import appeng.api.config.SecurityPermissions;
|
||||||
import appeng.api.config.Settings;
|
import appeng.api.config.Settings;
|
||||||
import appeng.api.crafting.ICraftingPatternDetails;
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||||
import appeng.container.guisync.GuiSync;
|
import appeng.container.guisync.GuiSync;
|
||||||
import appeng.container.slot.SlotMACPattern;
|
import appeng.container.slot.SlotMACPattern;
|
||||||
import appeng.container.slot.SlotOutput;
|
import appeng.container.slot.SlotOutput;
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ import net.minecraft.world.World;
|
|||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
import appeng.api.IAppEngApi;
|
import appeng.api.IAppEngApi;
|
||||||
import appeng.api.crafting.ICraftingPatternDetails;
|
|
||||||
import appeng.api.features.INetworkEncodable;
|
import appeng.api.features.INetworkEncodable;
|
||||||
import appeng.api.implementations.ICraftingPatternItem;
|
import appeng.api.implementations.ICraftingPatternItem;
|
||||||
import appeng.api.implementations.items.IBiometricCard;
|
import appeng.api.implementations.items.IBiometricCard;
|
||||||
import appeng.api.implementations.items.ISpatialStorageCell;
|
import appeng.api.implementations.items.ISpatialStorageCell;
|
||||||
import appeng.api.implementations.items.IStorageComponent;
|
import appeng.api.implementations.items.IStorageComponent;
|
||||||
import appeng.api.implementations.items.IUpgradeModule;
|
import appeng.api.implementations.items.IUpgradeModule;
|
||||||
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||||
import appeng.api.storage.ICellWorkbenchItem;
|
import appeng.api.storage.ICellWorkbenchItem;
|
||||||
import appeng.items.misc.ItemEncodedPattern;
|
import appeng.items.misc.ItemEncodedPattern;
|
||||||
import appeng.recipes.handlers.Inscribe;
|
import appeng.recipes.handlers.Inscribe;
|
||||||
|
|||||||
@@ -1,16 +1,30 @@
|
|||||||
package appeng.helpers;
|
package appeng.helpers;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.inventory.InventoryCrafting;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
import appeng.api.config.Actionable;
|
import appeng.api.config.Actionable;
|
||||||
|
import appeng.api.implementations.ICraftingPatternItem;
|
||||||
import appeng.api.implementations.tiles.ISegmentedInventory;
|
import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||||
import appeng.api.networking.GridFlags;
|
import appeng.api.networking.GridFlags;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
|
import appeng.api.networking.crafting.ICraftingMedium;
|
||||||
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||||
|
import appeng.api.networking.crafting.ICraftingProvider;
|
||||||
|
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
||||||
import appeng.api.networking.energy.IEnergySource;
|
import appeng.api.networking.energy.IEnergySource;
|
||||||
|
import appeng.api.networking.events.MECraftingPatternUpdate;
|
||||||
import appeng.api.networking.security.BaseActionSource;
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
import appeng.api.networking.security.MachineSource;
|
import appeng.api.networking.security.MachineSource;
|
||||||
import appeng.api.networking.ticking.IGridTickable;
|
import appeng.api.networking.ticking.IGridTickable;
|
||||||
@@ -45,7 +59,7 @@ import appeng.util.inv.IInventoryDestination;
|
|||||||
import appeng.util.inv.WrapperInvSlot;
|
import appeng.util.inv.WrapperInvSlot;
|
||||||
|
|
||||||
public class DualityInterface implements IGridTickable, ISegmentedInventory, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory,
|
public class DualityInterface implements IGridTickable, ISegmentedInventory, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory,
|
||||||
IConfigureableObject, IConfigManagerHost
|
IConfigureableObject, IConfigManagerHost, ICraftingProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
final int sides[] = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };
|
final int sides[] = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };
|
||||||
@@ -57,6 +71,45 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
BaseActionSource mySrc;
|
BaseActionSource mySrc;
|
||||||
ConfigManager cm = new ConfigManager( this );
|
ConfigManager cm = new ConfigManager( this );
|
||||||
|
|
||||||
|
List<ICraftingPatternDetails> craftingList = null;
|
||||||
|
List<ItemStack> waitingToSend = null;
|
||||||
|
|
||||||
|
public boolean hasItemsToSend()
|
||||||
|
{
|
||||||
|
return waitingToSend != null && !waitingToSend.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addToCraftingList(ItemStack is)
|
||||||
|
{
|
||||||
|
if ( is == null )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( is.getItem() instanceof ICraftingPatternItem )
|
||||||
|
{
|
||||||
|
ICraftingPatternItem cpi = (ICraftingPatternItem) is.getItem();
|
||||||
|
ICraftingPatternDetails details = cpi.getPatternForItem( is, iHost.getTileEntity().getWorldObj() );
|
||||||
|
|
||||||
|
if ( details != null )
|
||||||
|
{
|
||||||
|
if ( craftingList == null )
|
||||||
|
craftingList = new LinkedList();
|
||||||
|
|
||||||
|
craftingList.add( details );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addToSendList(ItemStack is)
|
||||||
|
{
|
||||||
|
if ( is == null )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( waitingToSend == null )
|
||||||
|
waitingToSend = new LinkedList();
|
||||||
|
|
||||||
|
waitingToSend.add( is );
|
||||||
|
}
|
||||||
|
|
||||||
public DualityInterface(AENetworkProxy prox, IInterfaceHost ih) {
|
public DualityInterface(AENetworkProxy prox, IInterfaceHost ih) {
|
||||||
gridProxy = prox;
|
gridProxy = prox;
|
||||||
gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||||
@@ -120,10 +173,37 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
config.writeToNBT( data, "config" );
|
config.writeToNBT( data, "config" );
|
||||||
patterns.writeToNBT( data, "patterns" );
|
patterns.writeToNBT( data, "patterns" );
|
||||||
storage.writeToNBT( data, "storage" );
|
storage.writeToNBT( data, "storage" );
|
||||||
|
|
||||||
|
NBTTagList waitingToSend = new NBTTagList();
|
||||||
|
if ( this.waitingToSend != null )
|
||||||
|
{
|
||||||
|
for (ItemStack is : this.waitingToSend)
|
||||||
|
{
|
||||||
|
NBTTagCompound item = new NBTTagCompound();
|
||||||
|
is.writeToNBT( item );
|
||||||
|
waitingToSend.appendTag( item );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data.setTag( "waitingToSend", waitingToSend );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound data)
|
public void readFromNBT(NBTTagCompound data)
|
||||||
{
|
{
|
||||||
|
this.waitingToSend = null;
|
||||||
|
NBTTagList waitingList = data.getTagList( "waitingToSend", 10 );
|
||||||
|
if ( waitingList != null )
|
||||||
|
{
|
||||||
|
for (int x = 0; x < waitingList.tagCount(); x++)
|
||||||
|
{
|
||||||
|
NBTTagCompound c = waitingList.getCompoundTagAt( x );
|
||||||
|
if ( c != null )
|
||||||
|
{
|
||||||
|
ItemStack is = ItemStack.loadItemStackFromNBT( c );
|
||||||
|
addToSendList( is );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
config.readFromNBT( data, "config" );
|
config.readFromNBT( data, "config" );
|
||||||
patterns.readFromNBT( data, "patterns" );
|
patterns.readFromNBT( data, "patterns" );
|
||||||
storage.readFromNBT( data, "storage" );
|
storage.readFromNBT( data, "storage" );
|
||||||
@@ -349,7 +429,14 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
readConfig();
|
readConfig();
|
||||||
else if ( inv == patterns )
|
else if ( inv == patterns )
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gridProxy.getGrid().postEvent( new MECraftingPatternUpdate( this ) );
|
||||||
|
}
|
||||||
|
catch (GridAccessException e)
|
||||||
|
{
|
||||||
|
// :P
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( inv == storage && slot >= 0 )
|
else if ( inv == storage && slot >= 0 )
|
||||||
{
|
{
|
||||||
@@ -378,8 +465,8 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
|
|
||||||
public boolean hasWorkToDo()
|
public boolean hasWorkToDo()
|
||||||
{
|
{
|
||||||
return requireWork[0] != null || requireWork[1] != null || requireWork[2] != null || requireWork[3] != null || requireWork[4] != null
|
return hasItemsToSend() || requireWork[0] != null || requireWork[1] != null || requireWork[2] != null || requireWork[3] != null
|
||||||
|| requireWork[5] != null || requireWork[6] != null || requireWork[7] != null;
|
|| requireWork[4] != null || requireWork[5] != null || requireWork[6] != null || requireWork[7] != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean updateStorage()
|
private boolean updateStorage()
|
||||||
@@ -501,6 +588,92 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table, ForgeDirection where)
|
||||||
|
{
|
||||||
|
if ( hasItemsToSend() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TileEntity tile = iHost.getTileEntity();
|
||||||
|
World w = tile.getWorldObj();
|
||||||
|
|
||||||
|
EnumSet<ForgeDirection> possibleDirections = iHost.getTargets();
|
||||||
|
for (ForgeDirection s : possibleDirections)
|
||||||
|
{
|
||||||
|
TileEntity te = w.getTileEntity( tile.xCoord + s.offsetX, tile.yCoord + s.offsetY, tile.zCoord + s.offsetZ );
|
||||||
|
if ( te instanceof ICraftingMedium )
|
||||||
|
{
|
||||||
|
if ( ((ICraftingMedium) te).pushPattern( patternDetails, table, s.getOpposite() ) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
|
||||||
|
if ( ad != null )
|
||||||
|
{
|
||||||
|
possibleDirections.remove( s );
|
||||||
|
|
||||||
|
for (int x = 0; x < table.getSizeInventory(); x++)
|
||||||
|
{
|
||||||
|
ItemStack is = table.getStackInSlot( x );
|
||||||
|
if ( is != null )
|
||||||
|
{
|
||||||
|
addToSendList( ad.addItems( is ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pushItemsOut( possibleDirections );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pushItemsOut(EnumSet<ForgeDirection> possibleDirections)
|
||||||
|
{
|
||||||
|
if ( hasItemsToSend() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
TileEntity tile = iHost.getTileEntity();
|
||||||
|
World w = tile.getWorldObj();
|
||||||
|
|
||||||
|
Iterator<ItemStack> i = waitingToSend.iterator();
|
||||||
|
while (i.hasNext())
|
||||||
|
{
|
||||||
|
ItemStack whatToSend = i.next();
|
||||||
|
|
||||||
|
for (ForgeDirection s : possibleDirections)
|
||||||
|
{
|
||||||
|
TileEntity te = w.getTileEntity( tile.xCoord + s.offsetX, tile.yCoord + s.offsetY, tile.zCoord + s.offsetZ );
|
||||||
|
|
||||||
|
InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
|
||||||
|
if ( ad != null )
|
||||||
|
{
|
||||||
|
whatToSend = ad.addItems( whatToSend );
|
||||||
|
if ( whatToSend == null )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( whatToSend == null )
|
||||||
|
i.remove();
|
||||||
|
else
|
||||||
|
whatToSend.stackSize = whatToSend.stackSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( waitingToSend.isEmpty() )
|
||||||
|
waitingToSend = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void provideCrafting(ICraftingProviderHelper craftingTracker)
|
||||||
|
{
|
||||||
|
for (ICraftingPatternDetails details : craftingList)
|
||||||
|
craftingTracker.addCraftingOption( details );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
package appeng.helpers;
|
package appeng.helpers;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import appeng.api.networking.crafting.ICraftingProvider;
|
||||||
import appeng.api.networking.security.IActionHost;
|
import appeng.api.networking.security.IActionHost;
|
||||||
|
|
||||||
public interface IInterfaceHost extends IActionHost
|
public interface IInterfaceHost extends IActionHost, ICraftingProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
DualityInterface getInterfaceDuality();
|
DualityInterface getInterfaceDuality();
|
||||||
|
|
||||||
|
EnumSet<ForgeDirection> getTargets();
|
||||||
|
|
||||||
TileEntity getTileEntity();
|
TileEntity getTileEntity();
|
||||||
|
|
||||||
void saveChanges();
|
void saveChanges();
|
||||||
|
|||||||
+19
-10
@@ -13,7 +13,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
import appeng.api.crafting.ICraftingPatternDetails;
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
import appeng.container.ContainerNull;
|
import appeng.container.ContainerNull;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
@@ -21,16 +21,18 @@ import appeng.util.Platform;
|
|||||||
public class PatternHelper implements ICraftingPatternDetails
|
public class PatternHelper implements ICraftingPatternDetails
|
||||||
{
|
{
|
||||||
|
|
||||||
InventoryCrafting crafting = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
final ItemStack patternItem;
|
||||||
InventoryCrafting testFrame = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
|
||||||
|
|
||||||
ItemStack correctOutput;
|
final InventoryCrafting crafting = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
||||||
IRecipe standardRecipe;
|
final InventoryCrafting testFrame = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
||||||
|
|
||||||
IAEItemStack inputs[];
|
final ItemStack correctOutput;
|
||||||
IAEItemStack outputs[];
|
final IRecipe standardRecipe;
|
||||||
|
|
||||||
boolean isCrafting = false;
|
final IAEItemStack inputs[];
|
||||||
|
final IAEItemStack outputs[];
|
||||||
|
|
||||||
|
final boolean isCrafting;
|
||||||
|
|
||||||
class TestLookup
|
class TestLookup
|
||||||
{
|
{
|
||||||
@@ -75,7 +77,7 @@ public class PatternHelper implements ICraftingPatternDetails
|
|||||||
|
|
||||||
private void markItemAs(int slotIndex, ItemStack i, TestStatus b)
|
private void markItemAs(int slotIndex, ItemStack i, TestStatus b)
|
||||||
{
|
{
|
||||||
if ( b == TestStatus.TEST ||i.hasTagCompound())
|
if ( b == TestStatus.TEST || i.hasTagCompound() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(b == TestStatus.ACCEPT ? passCache : failCache).add( new TestLookup( slotIndex, i ) );
|
(b == TestStatus.ACCEPT ? passCache : failCache).add( new TestLookup( slotIndex, i ) );
|
||||||
@@ -105,11 +107,12 @@ public class PatternHelper implements ICraftingPatternDetails
|
|||||||
NBTTagCompound encodedValue = is.getTagCompound();
|
NBTTagCompound encodedValue = is.getTagCompound();
|
||||||
|
|
||||||
if ( encodedValue == null )
|
if ( encodedValue == null )
|
||||||
return;
|
throw new RuntimeException( "No pattern here!" );
|
||||||
|
|
||||||
NBTTagList inTag = encodedValue.getTagList( "in", 10 );
|
NBTTagList inTag = encodedValue.getTagList( "in", 10 );
|
||||||
NBTTagList outTag = encodedValue.getTagList( "out", 10 );
|
NBTTagList outTag = encodedValue.getTagList( "out", 10 );
|
||||||
isCrafting = encodedValue.getBoolean( "crafting" );
|
isCrafting = encodedValue.getBoolean( "crafting" );
|
||||||
|
patternItem = is;
|
||||||
|
|
||||||
if ( isCrafting == false )
|
if ( isCrafting == false )
|
||||||
throw new RuntimeException( "Only crafting recipes supported." );
|
throw new RuntimeException( "Only crafting recipes supported." );
|
||||||
@@ -243,4 +246,10 @@ public class PatternHelper implements ICraftingPatternDetails
|
|||||||
return outputs;
|
return outputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getPattern()
|
||||||
|
{
|
||||||
|
return patternItem;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.client.MinecraftForgeClient;
|
import net.minecraftforge.client.MinecraftForgeClient;
|
||||||
import appeng.api.crafting.ICraftingPatternDetails;
|
|
||||||
import appeng.api.implementations.ICraftingPatternItem;
|
import appeng.api.implementations.ICraftingPatternItem;
|
||||||
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||||
import appeng.client.render.items.ItemEncodedPatternRenderer;
|
import appeng.client.render.items.ItemEncodedPatternRenderer;
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
import appeng.core.localization.GuiText;
|
import appeng.core.localization.GuiText;
|
||||||
|
|||||||
Vendored
+65
@@ -0,0 +1,65 @@
|
|||||||
|
package appeng.me.cache;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import appeng.api.networking.IGridCache;
|
||||||
|
import appeng.api.networking.IGridHost;
|
||||||
|
import appeng.api.networking.IGridNode;
|
||||||
|
import appeng.api.networking.IGridStorage;
|
||||||
|
import appeng.api.networking.crafting.ICraftingProvider;
|
||||||
|
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||||
|
|
||||||
|
public class CraftingCache implements IGridCache
|
||||||
|
{
|
||||||
|
|
||||||
|
HashSet<CraftingCPUCluster> cpuClusters = new HashSet();
|
||||||
|
HashSet<ICraftingProvider> providers = new HashSet();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdateTick()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeNode(IGridNode gridNode, IGridHost machine)
|
||||||
|
{
|
||||||
|
if ( machine instanceof ICraftingProvider )
|
||||||
|
providers.remove( machine );
|
||||||
|
|
||||||
|
updatePatterns();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addNode(IGridNode gridNode, IGridHost machine)
|
||||||
|
{
|
||||||
|
if ( machine instanceof ICraftingProvider )
|
||||||
|
providers.add( (ICraftingProvider) machine );
|
||||||
|
|
||||||
|
updatePatterns();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePatterns()
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSplit(IGridStorage destinationStorage)
|
||||||
|
{ // nothing!
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onJoin(IGridStorage sourceStorage)
|
||||||
|
{
|
||||||
|
// nothing!
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populateGridStorage(IGridStorage destinationStorage)
|
||||||
|
{
|
||||||
|
// nothing!
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package appeng.me.cluster.implementations;
|
||||||
|
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import appeng.api.util.WorldCoord;
|
||||||
|
import appeng.me.cluster.IAECluster;
|
||||||
|
import appeng.me.cluster.IAEMultiBlock;
|
||||||
|
import appeng.me.cluster.MBCalculator;
|
||||||
|
import appeng.tile.crafting.TileCraftingTile;
|
||||||
|
import appeng.tile.qnb.TileQuantumBridge;
|
||||||
|
|
||||||
|
public class CraftingCPUCalculator extends MBCalculator
|
||||||
|
{
|
||||||
|
|
||||||
|
TileCraftingTile tqb;
|
||||||
|
|
||||||
|
public CraftingCPUCalculator(IAEMultiBlock t) {
|
||||||
|
super( t );
|
||||||
|
tqb = (TileCraftingTile) t;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValidTile(TileEntity te)
|
||||||
|
{
|
||||||
|
return te instanceof TileQuantumBridge;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkMultiblockScale(WorldCoord min, WorldCoord max)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTiles(IAECluster cl, World w, WorldCoord min, WorldCoord max)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IAECluster createCluster(World w, WorldCoord min, WorldCoord max)
|
||||||
|
{
|
||||||
|
return new CraftingCPUCluster( min, max );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disconnect()
|
||||||
|
{
|
||||||
|
tqb.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean verifyInternalStructure(World w, WorldCoord min, WorldCoord max)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int x = min.x; x <= max.x; x++)
|
||||||
|
{
|
||||||
|
for (int y = min.y; y <= max.y; y++)
|
||||||
|
{
|
||||||
|
for (int z = min.z; z <= max.z; z++)
|
||||||
|
{
|
||||||
|
IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity( x, y, z );
|
||||||
|
|
||||||
|
if ( !te.isValid() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package appeng.me.cluster.implementations;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
import appeng.api.networking.IGridHost;
|
||||||
|
import appeng.api.util.WorldCoord;
|
||||||
|
import appeng.me.cluster.IAECluster;
|
||||||
|
|
||||||
|
public class CraftingCPUCluster implements IAECluster
|
||||||
|
{
|
||||||
|
|
||||||
|
public WorldCoord min;
|
||||||
|
public WorldCoord max;
|
||||||
|
public boolean isDestroyed = false;
|
||||||
|
|
||||||
|
private LinkedList<IGridHost> tiles = new LinkedList();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<IGridHost> getTiles()
|
||||||
|
{
|
||||||
|
return tiles.iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CraftingCPUCluster(WorldCoord _min, WorldCoord _max) {
|
||||||
|
min = _min;
|
||||||
|
max = _max;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateStatus(boolean updateGrid)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy()
|
||||||
|
{
|
||||||
|
if ( isDestroyed )
|
||||||
|
return;
|
||||||
|
isDestroyed = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
package appeng.parts.misc;
|
package appeng.parts.misc;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.ISidedInventory;
|
import net.minecraft.inventory.ISidedInventory;
|
||||||
|
import net.minecraft.inventory.InventoryCrafting;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
@@ -14,6 +16,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||||||
import appeng.api.implementations.tiles.ISegmentedInventory;
|
import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||||
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||||
|
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
||||||
import appeng.api.networking.security.BaseActionSource;
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
import appeng.api.networking.ticking.IGridTickable;
|
import appeng.api.networking.ticking.IGridTickable;
|
||||||
import appeng.api.networking.ticking.TickRateModulation;
|
import appeng.api.networking.ticking.TickRateModulation;
|
||||||
@@ -313,4 +317,23 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISeg
|
|||||||
{
|
{
|
||||||
return duality.getMonitorable( side, src, this );
|
return duality.getMonitorable( side, src, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table, ForgeDirection where)
|
||||||
|
{
|
||||||
|
return duality.pushPattern( patternDetails, table, where );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void provideCrafting(ICraftingProviderHelper craftingTracker)
|
||||||
|
{
|
||||||
|
duality.provideCrafting( craftingTracker );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumSet<ForgeDirection> getTargets()
|
||||||
|
{
|
||||||
|
return EnumSet.of( side );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package appeng.tile.crafting;
|
||||||
|
|
||||||
|
import appeng.me.cluster.IAECluster;
|
||||||
|
import appeng.me.cluster.IAEMultiBlock;
|
||||||
|
import appeng.tile.AEBaseTile;
|
||||||
|
|
||||||
|
public class TileCraftingTile extends AEBaseTile implements IAEMultiBlock
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disconnect()
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IAECluster getCluster()
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid()
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,10 +14,10 @@ import appeng.api.config.PowerMultiplier;
|
|||||||
import appeng.api.config.RedstoneMode;
|
import appeng.api.config.RedstoneMode;
|
||||||
import appeng.api.config.Settings;
|
import appeng.api.config.Settings;
|
||||||
import appeng.api.config.Upgrades;
|
import appeng.api.config.Upgrades;
|
||||||
import appeng.api.crafting.ICraftingMedium;
|
|
||||||
import appeng.api.crafting.ICraftingPatternDetails;
|
|
||||||
import appeng.api.implementations.IUpgradeableHost;
|
import appeng.api.implementations.IUpgradeableHost;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
|
import appeng.api.networking.crafting.ICraftingMedium;
|
||||||
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||||
import appeng.api.networking.ticking.IGridTickable;
|
import appeng.api.networking.ticking.IGridTickable;
|
||||||
import appeng.api.networking.ticking.TickRateModulation;
|
import appeng.api.networking.ticking.TickRateModulation;
|
||||||
import appeng.api.networking.ticking.TickingRequest;
|
import appeng.api.networking.ticking.TickingRequest;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package appeng.tile.misc;
|
|||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.inventory.InventoryCrafting;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
@@ -10,6 +11,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||||||
import appeng.api.implementations.tiles.ISegmentedInventory;
|
import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||||
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||||
|
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
||||||
import appeng.api.networking.security.BaseActionSource;
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
import appeng.api.networking.ticking.IGridTickable;
|
import appeng.api.networking.ticking.IGridTickable;
|
||||||
import appeng.api.networking.ticking.TickRateModulation;
|
import appeng.api.networking.ticking.TickRateModulation;
|
||||||
@@ -203,4 +206,24 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IS
|
|||||||
return duality.getConfigManager();
|
return duality.getConfigManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table, ForgeDirection where)
|
||||||
|
{
|
||||||
|
return duality.pushPattern( patternDetails, table, where );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void provideCrafting(ICraftingProviderHelper craftingTracker)
|
||||||
|
{
|
||||||
|
duality.provideCrafting( craftingTracker );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumSet<ForgeDirection> getTargets()
|
||||||
|
{
|
||||||
|
if ( pointAt == null || pointAt == ForgeDirection.UNKNOWN )
|
||||||
|
return EnumSet.complementOf( EnumSet.of( ForgeDirection.UNKNOWN ) );
|
||||||
|
return EnumSet.of( pointAt );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user