Add CraftTweaker support (#3231)
This commit is contained in:
parent
90c17c09a8
commit
959672dae3
52
README.md
52
README.md
|
@ -14,6 +14,7 @@
|
|||
* [Building](#building)
|
||||
* [Contribution](#contribution)
|
||||
* [API](#applied-energistics-2-api)
|
||||
* [CraftTweaker](#applied-energistics-2-crafttweaker)
|
||||
* [Localization](#applied-energistics-2-localization)
|
||||
* [Credits](#credits)
|
||||
|
||||
|
@ -154,6 +155,57 @@ Where the __ are filled in with the correct version criteria; AE2 is available f
|
|||
|
||||
An example string would be `appeng:appliedenergistics2:rv2-alpha-30:dev`
|
||||
|
||||
## Applied Energistics 2 CraftTweaker
|
||||
|
||||
### Inscriber
|
||||
Add a recipe. When `inscribe` is true the bottom and top inputs are not consumed.
|
||||
|
||||
mods.appliedenergistics2.Inscriber.addRecipe(ItemStack output, ItemStack input, boolean inscribe,
|
||||
@Optional ItemStack topInput, @Optional ItemStack bottomInput );
|
||||
|
||||
Remove all recipes for this output stack.
|
||||
|
||||
mods.appliedenergistics2.Inscriber.removeRecipe(ItemStack output);
|
||||
|
||||
### Grindstone
|
||||
Add a recipe.
|
||||
|
||||
mods.appliedenergistics2.Grinder.addRecipe( ItemStack output, ItemStack input, int turns,
|
||||
@Optional ItemStack secondary1Output, @Optional float secondary1Chance,
|
||||
@Optional ItemStack secondary2Output, @Optional float secondary2Chance);
|
||||
|
||||
Remove recipes for this input.
|
||||
|
||||
mods.appliedenergistics2.Grinder.removeRecipe(ItemStack input);
|
||||
|
||||
### Spatial
|
||||
Whitelist a TileEntity class for Spatial IO.
|
||||
|
||||
mods.appliedenergistics2.Spatial.whitelistEntity( String fullEntityClassName );
|
||||
|
||||
### Attunement
|
||||
Attune a ItemStack or ModID to a specific P2P-Tunnel type. ModID's are used as fallback when no ItemStack was found.
|
||||
|
||||
mods.appliedenergistics2.Attunement.attuneME( ItemStack itemStack );
|
||||
mods.appliedenergistics2.Attunement.attuneME( String modID );
|
||||
mods.appliedenergistics2.Attunement.attuneItem( ItemStack itemStack );
|
||||
mods.appliedenergistics2.Attunement.attuneItem( String modID );
|
||||
mods.appliedenergistics2.Attunement.attuneFluid( ItemStack itemStack );
|
||||
mods.appliedenergistics2.Attunement.attuneFluid( String modID );
|
||||
mods.appliedenergistics2.Attunement.attuneRedstone( ItemStack itemStack );
|
||||
mods.appliedenergistics2.Attunement.attuneRedstone( String modID );
|
||||
mods.appliedenergistics2.Attunement.attuneRF( ItemStack itemStack );
|
||||
mods.appliedenergistics2.Attunement.attuneRF( String modID );
|
||||
mods.appliedenergistics2.Attunement.attuneIC2( ItemStack itemStack );
|
||||
mods.appliedenergistics2.Attunement.attuneIC2( String modID );
|
||||
mods.appliedenergistics2.Attunement.attuneLight( ItemStack itemStack );
|
||||
mods.appliedenergistics2.Attunement.attuneLight( String modID );
|
||||
|
||||
### Cannon
|
||||
Add ammo types for the matter cannon.
|
||||
|
||||
mods.appliedenergistics2.Cannon.registerAmmo( ItemStack itemStack, double weight );
|
||||
|
||||
## Applied Energistics 2 Localization
|
||||
|
||||
### English Text
|
||||
|
|
|
@ -58,6 +58,11 @@ repositories {
|
|||
name 'tehnut'
|
||||
url "http://tehnut.info/maven"
|
||||
}
|
||||
|
||||
maven { // CraftTweaker
|
||||
name 'jared maven'
|
||||
url "http://maven.blamejared.com/"
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
|
@ -77,6 +82,7 @@ dependencies {
|
|||
compileOnly "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
|
||||
compileOnly "mcjty.theoneprobe:TheOneProbe-1.12:${top_version}:api"
|
||||
compileOnly "cofh:CoFHCore:${cofhcore_version}:deobf"
|
||||
compileOnly "CraftTweaker2:CraftTweaker2-API:4.+"
|
||||
|
||||
// at runtime, use the full JEI jar
|
||||
runtime "mezz.jei:jei_${minecraft_version}:${jei_version}"
|
||||
|
|
|
@ -189,6 +189,8 @@ public final class AppEng
|
|||
AppEng.proxy.preinit();
|
||||
}
|
||||
|
||||
IntegrationRegistry.INSTANCE.preInit();
|
||||
|
||||
if( versionCheckerConfig.isVersionCheckingEnabled() )
|
||||
{
|
||||
final VersionChecker versionChecker = new VersionChecker( versionCheckerConfig );
|
||||
|
|
|
@ -47,13 +47,16 @@ public enum IntegrationRegistry
|
|||
this.modules.add( new IntegrationNode( type.dspName, type.modID, type ) );
|
||||
}
|
||||
|
||||
public void init()
|
||||
public void preInit()
|
||||
{
|
||||
for( final IntegrationNode node : this.modules )
|
||||
{
|
||||
node.call( IntegrationStage.PRE_INIT );
|
||||
}
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
for( final IntegrationNode node : this.modules )
|
||||
{
|
||||
node.call( IntegrationStage.INIT );
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package appeng.integration;
|
||||
|
||||
|
||||
import appeng.integration.modules.crafttweaker.CTModule;
|
||||
import appeng.integration.modules.ic2.IC2Module;
|
||||
import appeng.integration.modules.jei.JEIModule;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeModule;
|
||||
|
@ -73,7 +74,16 @@ public enum IntegrationType
|
|||
}
|
||||
},
|
||||
|
||||
TESLA( IntegrationSide.BOTH, "Tesla", "tesla" );
|
||||
TESLA( IntegrationSide.BOTH, "Tesla", "tesla" ),
|
||||
|
||||
CRAFTTWEAKER( IntegrationSide.BOTH, "CraftTweaker", "crafttweaker" )
|
||||
{
|
||||
@Override
|
||||
public IIntegrationModule createInstance()
|
||||
{
|
||||
return new CTModule();
|
||||
}
|
||||
};
|
||||
|
||||
public final IntegrationSide side;
|
||||
public final String dspName;
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
|
||||
public interface ICraftTweaker extends IIntegrationModule
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.crafttweaker;
|
||||
|
||||
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.TunnelType;
|
||||
import appeng.api.features.IP2PTunnelRegistry;
|
||||
|
||||
|
||||
@ZenClass( "mods.appliedenergistics2.Attunement" )
|
||||
public class AttunementRegistry
|
||||
{
|
||||
private AttunementRegistry()
|
||||
{
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneME( IIngredient itemStack )
|
||||
{
|
||||
attune( itemStack, TunnelType.ME );
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneME( String modId )
|
||||
{
|
||||
attune( modId, TunnelType.ME );
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneItem( IIngredient itemStack )
|
||||
{
|
||||
attune( itemStack, TunnelType.ITEM );
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneItem( String modId )
|
||||
{
|
||||
attune( modId, TunnelType.ITEM );
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneFluid( IIngredient itemStack )
|
||||
{
|
||||
attune( itemStack, TunnelType.FLUID );
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneFluid( String modId )
|
||||
{
|
||||
attune( modId, TunnelType.FLUID );
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneRedstone( IIngredient itemStack )
|
||||
{
|
||||
attune( itemStack, TunnelType.REDSTONE );
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneRedstone( String modId )
|
||||
{
|
||||
attune( modId, TunnelType.REDSTONE );
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneRF( IIngredient itemStack )
|
||||
{
|
||||
attune( itemStack, TunnelType.FE_POWER );
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneRF( String modId )
|
||||
{
|
||||
attune( modId, TunnelType.FE_POWER );
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneIC2( IIngredient itemStack )
|
||||
{
|
||||
attune( itemStack, TunnelType.IC2_POWER );
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneIC2( String modId )
|
||||
{
|
||||
attune( modId, TunnelType.IC2_POWER );
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneLight( IIngredient itemStack )
|
||||
{
|
||||
attune( itemStack, TunnelType.LIGHT );
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void attuneLight( String modId )
|
||||
{
|
||||
attune( modId, TunnelType.LIGHT );
|
||||
}
|
||||
|
||||
private static void attune( IIngredient itemStack, TunnelType type )
|
||||
{
|
||||
IP2PTunnelRegistry registry = AEApi.instance().registries().p2pTunnel();
|
||||
CTModule.toStacks( itemStack ).ifPresent( c -> c.forEach( i -> registry.addNewAttunement( i, type ) ) );
|
||||
}
|
||||
|
||||
private static void attune( String modid, TunnelType type )
|
||||
{
|
||||
AEApi.instance().registries().p2pTunnel().addNewAttunement( modid, type );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.crafttweaker;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import crafttweaker.CraftTweakerAPI;
|
||||
import crafttweaker.IAction;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
|
||||
import appeng.integration.abstraction.ICraftTweaker;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class CTModule implements ICraftTweaker
|
||||
{
|
||||
static final List<IAction> MODIFICATIONS = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void preInit()
|
||||
{
|
||||
CraftTweakerAPI.registerClass( GrinderRecipes.class );
|
||||
CraftTweakerAPI.registerClass( InscriberRecipes.class );
|
||||
CraftTweakerAPI.registerClass( SpatialRegistry.class );
|
||||
CraftTweakerAPI.registerClass( AttunementRegistry.class );
|
||||
CraftTweakerAPI.registerClass( CannonRegistry.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
MODIFICATIONS.forEach( CraftTweakerAPI::apply );
|
||||
}
|
||||
|
||||
public static ItemStack toStack( IItemStack iStack )
|
||||
{
|
||||
if( iStack == null )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (ItemStack) iStack.getInternal();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ItemStack> toStackExpand( IItemStack iStack )
|
||||
{
|
||||
if( iStack == null )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack is = (ItemStack) iStack.getInternal();
|
||||
if( !is.isItemStackDamageable() && is.getItemDamage() == OreDictionary.WILDCARD_VALUE )
|
||||
{
|
||||
NonNullList<ItemStack> ret = NonNullList.create();
|
||||
is.getItem().getSubItems( CreativeTabs.SEARCH, ret );
|
||||
return ret.stream().map( i -> new ItemStack( i.getItem(), iStack.getAmount(), i.getItemDamage() ) ).collect( Collectors.toList() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return Collections.singletonList( is );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<Collection<ItemStack>> toStacks( IIngredient ingredient )
|
||||
{
|
||||
if( ingredient == null )
|
||||
{
|
||||
return Optional.empty();
|
||||
}
|
||||
Set<ItemStack> ret = new TreeSet<>( CTModule::compareItemStacks );
|
||||
ingredient.getItems().stream().map( CTModule::toStackExpand ).forEach( ret::addAll );
|
||||
if( ret.isEmpty() )
|
||||
{
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of( ret );
|
||||
}
|
||||
|
||||
private static int compareItemStacks( ItemStack a, ItemStack b )
|
||||
{
|
||||
if( Platform.itemComparisons().isSameItem( a, b ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if( a == null )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if( b == null )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return System.identityHashCode( a ) - System.identityHashCode( b );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.crafttweaker;
|
||||
|
||||
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.IMatterCannonAmmoRegistry;
|
||||
|
||||
|
||||
@ZenClass( "mods.appliedenergistics2.Cannon" )
|
||||
public class CannonRegistry
|
||||
{
|
||||
private CannonRegistry()
|
||||
{
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void registerAmmo( IIngredient itemStack, double weight )
|
||||
{
|
||||
IMatterCannonAmmoRegistry registry = AEApi.instance().registries().matterCannon();
|
||||
CTModule.toStacks( itemStack ).ifPresent( c -> c.forEach( i -> registry.registerAmmo( i, weight ) ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.crafttweaker;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import crafttweaker.IAction;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.IGrinderRecipe;
|
||||
import appeng.api.features.IGrinderRecipeBuilder;
|
||||
|
||||
|
||||
@ZenClass( "mods.appliedenergistics2.Grinder" )
|
||||
public class GrinderRecipes
|
||||
{
|
||||
private GrinderRecipes()
|
||||
{
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe( IItemStack output, IIngredient input, int turns, @stanhebben.zenscript.annotations.Optional IItemStack secondary1Output, @stanhebben.zenscript.annotations.Optional Float secondary1Chance, @stanhebben.zenscript.annotations.Optional IItemStack secondary2Output, @stanhebben.zenscript.annotations.Optional Float secondary2Chance )
|
||||
{
|
||||
Collection<ItemStack> inStacks = CTModule.toStacks( input ).orElse( Collections.emptySet() );
|
||||
|
||||
for( ItemStack inStack : inStacks )
|
||||
{
|
||||
IGrinderRecipeBuilder builder = AEApi.instance().registries().grinder().builder();
|
||||
builder.withInput( inStack )
|
||||
.withOutput( CTModule.toStack( output ) )
|
||||
.withTurns( turns );
|
||||
|
||||
final ItemStack s1 = CTModule.toStack( secondary1Output );
|
||||
if( !s1.isEmpty() )
|
||||
{
|
||||
builder.withFirstOptional( s1, secondary1Chance == null ? 1.0f : secondary1Chance );
|
||||
}
|
||||
final ItemStack s2 = CTModule.toStack( secondary2Output );
|
||||
if( !s2.isEmpty() )
|
||||
{
|
||||
builder.withFirstOptional( s2, secondary2Chance == null ? 1.0f : secondary2Chance );
|
||||
}
|
||||
CTModule.MODIFICATIONS.add( new Add( builder.build() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe( IIngredient input )
|
||||
{
|
||||
for( ItemStack inStack : CTModule.toStacks( input ).orElse( Collections.emptySet() ) )
|
||||
{
|
||||
CTModule.MODIFICATIONS.add( new Remove( inStack ) );
|
||||
}
|
||||
}
|
||||
|
||||
private static class Add implements IAction
|
||||
{
|
||||
private final IGrinderRecipe entry;
|
||||
|
||||
private Add( IGrinderRecipe entry )
|
||||
{
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply()
|
||||
{
|
||||
AEApi.instance().registries().grinder().addRecipe( entry );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe()
|
||||
{
|
||||
return "Adding Grinder Entry for " + entry.getInput().getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove implements IAction
|
||||
{
|
||||
private final ItemStack stack;
|
||||
|
||||
private Remove( ItemStack stack )
|
||||
{
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply()
|
||||
{
|
||||
IGrinderRecipe recipe = AEApi.instance().registries().grinder().getRecipeForInput( stack );
|
||||
if( recipe != null )
|
||||
{
|
||||
AEApi.instance().registries().grinder().removeRecipe( recipe );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe()
|
||||
{
|
||||
return "Removing Grinder Entry for " + stack.getDisplayName();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.crafttweaker;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import crafttweaker.IAction;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
import appeng.api.features.IInscriberRecipeBuilder;
|
||||
import appeng.api.features.IInscriberRegistry;
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
|
||||
|
||||
@ZenClass( "mods.appliedenergistics2.Inscriber" )
|
||||
public class InscriberRecipes
|
||||
{
|
||||
private InscriberRecipes()
|
||||
{
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe( IItemStack output, IIngredient input, boolean inscribe, @stanhebben.zenscript.annotations.Optional IIngredient top, @stanhebben.zenscript.annotations.Optional IIngredient bottom )
|
||||
{
|
||||
Optional<Collection<ItemStack>> inStacks = CTModule.toStacks( input );
|
||||
if( !inStacks.isPresent() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Collection<ItemStack> topList = CTModule.toStacks( top ).orElse( Collections.singleton( ItemStack.EMPTY ) );
|
||||
Collection<ItemStack> bottomList = CTModule.toStacks( bottom ).orElse( Collections.singleton( ItemStack.EMPTY ) );
|
||||
|
||||
for( ItemStack topStack : topList )
|
||||
{
|
||||
for( ItemStack bottomStack : bottomList )
|
||||
{
|
||||
final IInscriberRecipeBuilder builder = AEApi.instance().registries().inscriber().builder();
|
||||
builder.withProcessType( inscribe ? InscriberProcessType.INSCRIBE : InscriberProcessType.PRESS )
|
||||
.withOutput( CTModule.toStack( output ) )
|
||||
.withInputs( inStacks.get() );
|
||||
|
||||
if( !topStack.isEmpty() )
|
||||
{
|
||||
builder.withTopOptional( topStack );
|
||||
}
|
||||
if( !bottomStack.isEmpty() )
|
||||
{
|
||||
builder.withBottomOptional( bottomStack );
|
||||
}
|
||||
CTModule.MODIFICATIONS.add( new Add( builder.build() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe( IItemStack output )
|
||||
{
|
||||
CTModule.MODIFICATIONS.add( new Remove( (ItemStack) output.getInternal() ) );
|
||||
}
|
||||
|
||||
private static class Add implements IAction
|
||||
{
|
||||
private final IInscriberRecipe entry;
|
||||
|
||||
private Add( IInscriberRecipe entry )
|
||||
{
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply()
|
||||
{
|
||||
AEApi.instance().registries().inscriber().addRecipe( entry );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe()
|
||||
{
|
||||
return "Adding Inscriber Entry for " + entry.getOutput().getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove implements IAction
|
||||
{
|
||||
private final ItemStack stack;
|
||||
|
||||
private Remove( ItemStack stack )
|
||||
{
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply()
|
||||
{
|
||||
final IInscriberRegistry inscriber = AEApi.instance().registries().inscriber();
|
||||
inscriber.getRecipes()
|
||||
.stream()
|
||||
.filter( r -> r.getOutput().isItemEqual( this.stack ) )
|
||||
.collect( Collectors.toList() )
|
||||
.forEach( inscriber::removeRecipe );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe()
|
||||
{
|
||||
return "Removing Inscriber Entry for " + stack.getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.integration.modules.crafttweaker;
|
||||
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.AELog;
|
||||
|
||||
|
||||
@ZenClass( "mods.appliedenergistics2.Spatial" )
|
||||
public class SpatialRegistry
|
||||
{
|
||||
private SpatialRegistry()
|
||||
{
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void whitelistEntity( String entityClassName )
|
||||
{
|
||||
Class<? extends TileEntity> entityClass = loadClass( entityClassName );
|
||||
if( entityClass != null )
|
||||
{
|
||||
AEApi.instance().registries().movable().whiteListTileEntity( entityClass );
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
private static Class<? extends TileEntity> loadClass( String className )
|
||||
{
|
||||
try
|
||||
{
|
||||
return (Class<? extends TileEntity>) Class.forName( className );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
AELog.warn( e, "Failed to load TileEntity class '" + className + "'" );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue