Enable FZ Integration - Crafting and Barrels ( Untested ).

This commit is contained in:
AlgorithmX2 2014-03-18 12:54:57 -05:00
parent a475a3e91f
commit 9e85c33b16
7 changed files with 85 additions and 46 deletions

View file

@ -78,7 +78,7 @@ public class AppEng
// IntegrationSide.BOTH, "Mine Factory Reloaded", "MineFactoryReloaded", "MFR", // MFR
IntegrationSide.BOTH, "Deep Storage Unit", null, "DSU", // DSU
// IntegrationSide.BOTH, "Better Storage", "betterstorage", "BS", // BS
// IntegrationSide.BOTH, "Factorization", "factorization", "FZ", // FZ
IntegrationSide.BOTH, "Factorization", "factorization", "FZ", // FZ
// IntegrationSide.BOTH, "Forestry", "Forestry", "Forestry", // Forestry
// IntegrationSide.BOTH, "Mekanism", "Mekanism", "Mekanism", // MeK
IntegrationSide.CLIENT, "Waila", "Waila", "Waila", // Waila

View file

@ -130,6 +130,7 @@ import appeng.recipes.game.FacadeRecipe;
import appeng.recipes.game.ShapedRecipe;
import appeng.recipes.game.ShapelessRecipe;
import appeng.recipes.handlers.Grind;
import appeng.recipes.handlers.GrindFZ;
import appeng.recipes.handlers.Inscribe;
import appeng.recipes.handlers.Macerator;
import appeng.recipes.handlers.Press;
@ -177,6 +178,7 @@ public class Registration
recipeRegistery.addNewSubItemResolver( new AEItemResolver() );
recipeRegistery.addNewCraftHandler( "grind", Grind.class );
recipeRegistery.addNewCraftHandler( "grindfz", GrindFZ.class );
recipeRegistery.addNewCraftHandler( "pulverizer", Pulverizer.class );
recipeRegistery.addNewCraftHandler( "macerator", Macerator.class );

View file

@ -21,4 +21,6 @@ public interface IFZ
boolean isBarrel(TileEntity te);
void grinderRecipe(ItemStack is, ItemStack itemStack);
}

View file

@ -1,18 +1,17 @@
package appeng.integration.modules.dead;
package appeng.integration.modules;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import appeng.api.AEApi;
import appeng.api.storage.IMEInventory;
import appeng.integration.IIntegrationModule;
import appeng.integration.abstraction.IFZ;
import appeng.integration.modules.helpers.dead.FactorizationBarrel;
import appeng.integration.modules.helpers.dead.FactorizationHandler;
import appeng.integration.modules.helpers.FactorizationBarrel;
import appeng.integration.modules.helpers.FactorizationHandler;
import appeng.util.Platform;
/**
@ -29,26 +28,19 @@ public class FZ implements IFZ, IIntegrationModule
private static Method day_getMaxSize;
private static Field day_item;
private static Class barrelClass;
private static Method getItemCount;
private static Method setItemCount;
private static Method getMaxSize;
private static Field item;
@Override
public ItemStack barrelGetItem(TileEntity te)
{
try
{
ItemStack i;
ItemStack i = null;
if ( day_BarrelClass.isInstance( te ) )
i = (ItemStack) day_item.get( te );
else
i = (ItemStack) item.get( te );
if ( i != null )
i = Platform.cloneItemStack( i );
return i;
}
catch (IllegalArgumentException e)
@ -67,8 +59,6 @@ public class FZ implements IFZ, IIntegrationModule
{
if ( day_BarrelClass.isInstance( te ) )
return (Integer) day_getMaxSize.invoke( te );
else
return (Integer) getMaxSize.invoke( te );
}
catch (IllegalAccessException e)
{
@ -89,8 +79,6 @@ public class FZ implements IFZ, IIntegrationModule
{
if ( day_BarrelClass.isInstance( te ) )
return (Integer) day_getItemCount.invoke( te );
else
return (Integer) getItemCount.invoke( te );
}
catch (IllegalAccessException e)
{
@ -111,8 +99,6 @@ public class FZ implements IFZ, IIntegrationModule
{
if ( day_BarrelClass.isInstance( te ) )
day_item.set( te, input == null ? null : input.copy() );
else
item.set( te, input == null ? null : input.copy() );
te.markDirty();
}
@ -131,8 +117,6 @@ public class FZ implements IFZ, IIntegrationModule
{
if ( day_BarrelClass.isInstance( te ) )
day_setItemCount.invoke( te, max );
else
setItemCount.invoke( te, max );
te.markDirty();
}
@ -158,22 +142,14 @@ public class FZ implements IFZ, IIntegrationModule
{
if ( day_BarrelClass.isAssignableFrom( te.getClass() ) )
return true;
if ( barrelClass.isAssignableFrom( te.getClass() ) )
return true;
return false;
}
@Override
public void Init() throws Throwable
{
barrelClass = Class.forName( "factorization.weird.TileEntityBarrel" );
day_BarrelClass = Class.forName( "factorization.weird.TileEntityDayBarrel" );
getItemCount = barrelClass.getDeclaredMethod( "getItemCount", new Class[] {} );
setItemCount = barrelClass.getDeclaredMethod( "setItemCount", new Class[] { int.class } );
getMaxSize = barrelClass.getDeclaredMethod( "getMaxSize", new Class[] {} );
item = barrelClass.getDeclaredField( "item" );
day_getItemCount = day_BarrelClass.getDeclaredMethod( "getItemCount", new Class[] {} );
day_setItemCount = day_BarrelClass.getDeclaredMethod( "setItemCount", new Class[] { int.class } );
day_getMaxSize = day_BarrelClass.getDeclaredMethod( "getMaxSize", new Class[] {} );
@ -184,25 +160,13 @@ public class FZ implements IFZ, IIntegrationModule
public void PostInit()
{
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new FactorizationHandler() );
// certus quartz
grinderRecipe( AEApi.instance().materials().materialCertusQuartzCrystal.stack( 1 ), AEApi.instance().materials().materialCertusQuartzDust.stack( 1 ) );
grinderRecipe( AEApi.instance().materials().materialCertusQuartzCrystalCharged.stack( 1 ),
AEApi.instance().materials().materialCertusQuartzDust.stack( 1 ) );
// fluix
grinderRecipe( AEApi.instance().materials().materialFluixCrystal.stack( 1 ), AEApi.instance().materials().materialFluixDust.stack( 1 ) );
// nether quartz
grinderRecipe( new ItemStack( Item.netherQuartz ), AEApi.instance().materials().materialNetherQuartzDust.stack( 1 ) );
}
private void grinderRecipe(ItemStack in, ItemStack out)
public void grinderRecipe(ItemStack in, ItemStack out)
{
try
{
Class c = Class.forName( "factorization.common.TileEntityGrinder" );
Class c = Class.forName( "factorization.oreprocessing.TileEntityGrinder" );
Method m = c.getMethod( "addRecipe", Object.class, ItemStack.class, float.class );
m.invoke( c, in, out, 1.0 );
}

View file

@ -1,4 +1,4 @@
package appeng.integration.modules.helpers.dead;
package appeng.integration.modules.helpers;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;

View file

@ -1,4 +1,4 @@
package appeng.integration.modules.helpers.dead;
package appeng.integration.modules.helpers;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;

View file

@ -0,0 +1,71 @@
package appeng.recipes.handlers;
import java.util.List;
import net.minecraft.item.ItemStack;
import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RecipeError;
import appeng.api.exceptions.RegistrationError;
import appeng.api.recipes.ICraftHandler;
import appeng.api.recipes.IIngredient;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.integration.abstraction.IFZ;
import appeng.recipes.RecipeHandler;
import appeng.util.Platform;
public class GrindFZ implements ICraftHandler, IWebsiteSeralizer
{
IIngredient pro_input;
IIngredient pro_output[];
@Override
public void setup(List<List<IIngredient>> input, List<List<IIngredient>> output) throws RecipeError
{
if ( input.size() == 1 && output.size() == 1 )
{
int outs = output.get( 0 ).size();
if ( input.get( 0 ).size() == 1 && outs == 1 )
{
pro_input = input.get( 0 ).get( 0 );
pro_output = output.get( 0 ).toArray( new IIngredient[outs] );
return;
}
}
new RecipeError( "Grind must have a single input, and single output." );
}
@Override
public void register() throws RegistrationError, MissingIngredientError
{
if ( AppEng.instance.isIntegrationEnabled( "FZ" ) )
{
IFZ fz = (IFZ) AppEng.instance.getIntegration( "FZ" );
for (ItemStack is : pro_input.getItemStackSet())
{
try
{
fz.grinderRecipe( is, pro_output[0].getItemStack() );
}
catch (java.lang.RuntimeException err)
{
AELog.info( "FZ not happy - " + err.getMessage() );
}
}
}
}
@Override
public boolean canCraft(ItemStack output) throws RegistrationError, MissingIngredientError
{
return Platform.isSameItemPrecise( pro_output[0].getItemStack(), output );
}
@Override
public String getPattern(RecipeHandler h)
{
return null;
}
}