Crafting API Added
Fixed tons of issues with CPU multi block weirdness.
This commit is contained in:
@@ -21,6 +21,7 @@ import appeng.api.features.IRecipeHandlerRegistry;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.movable.IMovableRegistry;
|
||||
import appeng.api.networking.IGridCacheRegistry;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.pathing.IPathingGrid;
|
||||
import appeng.api.networking.security.ISecurityGrid;
|
||||
@@ -123,7 +124,7 @@ import appeng.items.tools.quartz.ToolQuartzPickaxe;
|
||||
import appeng.items.tools.quartz.ToolQuartzSpade;
|
||||
import appeng.items.tools.quartz.ToolQuartzSword;
|
||||
import appeng.items.tools.quartz.ToolQuartzWrench;
|
||||
import appeng.me.cache.CraftingCache;
|
||||
import appeng.me.cache.CraftingGridCache;
|
||||
import appeng.me.cache.EnergyGridCache;
|
||||
import appeng.me.cache.GridStorageCache;
|
||||
import appeng.me.cache.P2PCache;
|
||||
@@ -523,7 +524,7 @@ public class Registration
|
||||
gcr.registerGridCache( P2PCache.class, P2PCache.class );
|
||||
gcr.registerGridCache( ISpatialCache.class, SpatialPylonCache.class );
|
||||
gcr.registerGridCache( ISecurityGrid.class, SecurityCache.class );
|
||||
gcr.registerGridCache( CraftingCache.class, CraftingCache.class );
|
||||
gcr.registerGridCache( ICraftingGrid.class, CraftingGridCache.class );
|
||||
|
||||
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new AEExternalHandler() );
|
||||
|
||||
@@ -664,9 +665,9 @@ public class Registration
|
||||
|
||||
private void registerSpatial(boolean force)
|
||||
{
|
||||
if ( ! AEConfig.instance.isFeatureEnabled( AEFeature.SpatialIO ) )
|
||||
if ( !AEConfig.instance.isFeatureEnabled( AEFeature.SpatialIO ) )
|
||||
return;
|
||||
|
||||
|
||||
AEConfig config = AEConfig.instance;
|
||||
|
||||
if ( storageBiome == null )
|
||||
@@ -675,8 +676,8 @@ public class Registration
|
||||
{
|
||||
config.storageBiomeID = Platform.findEmpty( BiomeGenBase.getBiomeGenArray() );
|
||||
if ( config.storageBiomeID == -1 )
|
||||
throw new RuntimeException("Biome Array is full, please free up some Biome ID's or disable spatial.");
|
||||
|
||||
throw new RuntimeException( "Biome Array is full, please free up some Biome ID's or disable spatial." );
|
||||
|
||||
storageBiome = new BiomeGenStorage( config.storageBiomeID );
|
||||
config.save();
|
||||
}
|
||||
|
||||
@@ -4,19 +4,18 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingJob;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
@@ -25,7 +24,6 @@ import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.crafting.CraftingJob;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
@@ -34,22 +32,6 @@ public class PacketCraftRequest extends AppEngPacket
|
||||
|
||||
final public IAEItemStack slotItem;
|
||||
final public boolean heldShift;
|
||||
final public static ExecutorService craftingPool;
|
||||
|
||||
static
|
||||
{
|
||||
ThreadFactory factory = new ThreadFactory() {
|
||||
|
||||
@Override
|
||||
public Thread newThread(Runnable ar)
|
||||
{
|
||||
return new Thread( ar, "AE Crafting Calculator" );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
craftingPool = Executors.newCachedThreadPool( factory );
|
||||
}
|
||||
|
||||
// automatic.
|
||||
public PacketCraftRequest(ByteBuf stream) throws IOException {
|
||||
@@ -75,9 +57,12 @@ public class PacketCraftRequest extends AppEngPacket
|
||||
if ( g == null )
|
||||
return;
|
||||
|
||||
Future<ICraftingJob> futureJob = null;
|
||||
|
||||
try
|
||||
{
|
||||
CraftingJob cj = new CraftingJob( cca.getWorld(), cca, slotItem, Actionable.SIMULATE );
|
||||
ICraftingGrid cg = g.getCache( ICraftingGrid.class );
|
||||
futureJob = cg.beginCraftingJob( cca.getWorld(), cca.getGrid(), cca.getActionSrc(), slotItem, null );
|
||||
|
||||
ContainerOpenContext context = cca.openContext;
|
||||
if ( context != null )
|
||||
@@ -89,7 +74,7 @@ public class PacketCraftRequest extends AppEngPacket
|
||||
{
|
||||
ContainerCraftConfirm ccc = (ContainerCraftConfirm) player.openContainer;
|
||||
ccc.autoStart = heldShift;
|
||||
ccc.job = craftingPool.submit( cj, cj );
|
||||
ccc.job = futureJob;
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
@@ -97,6 +82,8 @@ public class PacketCraftRequest extends AppEngPacket
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
if ( futureJob != null )
|
||||
futureJob.cancel( true );
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user