Compare commits

...

40 Commits

Author SHA1 Message Date
yueh 030e0c6a14 Updated gradle.properties for deploying to multiple minecraft versions 2017-08-18 00:47:31 +02:00
fscan 8e4265aa33 P2P Tunnel improvements (#3039)
* Fix P2P Tunnels randomly resetting to ME
* Allow one way push and pull. Outputs can pull from the input side, input can push into outputs.
2017-08-18 00:44:19 +02:00
Gunther De Wachter 80eaa032b9 Fixes #3011: placing the last part in off-hand clearing main hand as well 2017-08-17 22:19:50 +02:00
yueh bee9c70497 Added 1.12.1 as accepted version. 2017-08-17 21:17:55 +02:00
yueh c4fa21c193 Removes coremod (#3038)
From now on every integration must not rely on method stripping through
a coremod or @Optional. Notable example for a very good solution is IC2.

As consequence this drops all support for RF and mods must support on of
our supported energy types. At the time of writing, ForgeEnergy and
IC2/EU.
2017-08-17 21:16:57 +02:00
Gunther De Wachter 8a7450168b Updated JEI plugin to newer API methods. 2017-08-17 20:41:20 +02:00
Gunther De Wachter 7cb641cdc8 Fix shift clicking memory card still triggering off-hand item/block usage. 2017-08-17 20:41:20 +02:00
Gunther De Wachter b5b8050c4c Added workaround for sorting items on amount with fake amount when showing crafting label 2017-08-17 20:41:20 +02:00
Gunther De Wachter e65083b045 Fixed dropping items on the ground when clicking on a crafting label with items in hand 2017-08-17 20:41:20 +02:00
yueh b61219ef88 Covered dense cables (#3030)
* Renamed all dense smart cable related things to include smart
* Added dense covered cables
* Added abstract PartDenseCable to reduce redundant code
* Added dense covered recipes

* Ensures ItemPart ordering to be consitent.

Now takes the metadata into account to preserve the ordering for colored
items instead of just the part type name and depend on the insertion
order of a hashmap.
2017-08-17 18:41:39 +02:00
yueh 4f9fd1b369 IC2 rework to avoid a coremod or @Optional (#3034)
* IC2 rework to avoid a coremod or @Optional

Updated IC2 dependency

Refactored IC2 itemcharging to use an IBackupElectricManager.
Allows charging any ae powered item by using an IBackupElectricManager
instead of having to implement IElectricItem and stripping it by some
sort.

Updated IAEItemPowerStorage to use Actionable for an easier handling
with power APIs supporting a simulation.

Refactored EU P2P to avoid method stripping
Use a modified internal BasicSinkSource instead of implementing
IEnergySource and IEnergySink directly on the tunnel.

Removed the superfluous EU P2P layers.

* Removed internalBattery due to being too complex

* Creative Energy Cell is not a chargeable item
2017-08-17 17:35:34 +02:00
yueh 630fae3f73 Fixes #3024: Crash on recipe lookup for disabled features (#3026)
* Fixes #3024: Crash on recipe lookup for disabled features

Adds a new recipe condition for a single AEFeature or a list of them.
Moved the factories to their own package, in preparation of phasing out
the old recipe handling.
2017-08-17 17:17:26 +02:00
yueh 488ef1b544 Fixes recipes to use correct ingredients
Fluix Pearls instead of Fluix Crystals for spatial related items.
Fluix cables for most items, not any cable to avoid loops or unwanted
crafting steps.
2017-08-17 15:12:34 +02:00
fscan 098ee2f000 Making charged certus ore glow again (#3035) 2017-08-17 11:01:31 +02:00
fscan 04d2b06c0d Ignore MOVE_REGION when clicking on crafting slots (#3032)
Exclude crafting slots from list of slots to move on space click.

Fixes #3031
2017-08-15 15:07:42 +02:00
fscan ac48ab02fc Fix crash in clearStack (#3033) 2017-08-15 15:05:12 +02:00
fscan 9022150e38 Fill existing stacks first when adding to player inventory. (#3025) 2017-08-14 11:03:53 +02:00
yueh 65c6d2249a Fixes encoding issues with spatial cell names 2017-08-13 19:02:03 +02:00
yueh 8e7f79a9ea Ensure gradle uses UTF-8 2017-08-12 16:35:38 +02:00
fscan 95b48b9438 Registration rework (#3018)
Refactored component registration.

Fixes #3008: crank rendering
2017-08-12 15:02:50 +02:00
yueh cdd76b7b22 Added helpers for hex and color output. (#3027) 2017-08-12 14:52:31 +02:00
fscan 3e2bc0e038 Inscriber improvements and fixes (#3028) 2017-08-12 14:52:01 +02:00
yueh eec3e59eea Add missing annotations 2017-08-11 21:44:30 +02:00
yueh e39855b48f Use qualified method and field access 2017-08-11 21:43:47 +02:00
yueh cdcab7d91c Organise Imports 2017-08-11 21:42:26 +02:00
yueh 27ad2c2b96 Code format 2017-08-11 21:41:51 +02:00
yueh 542a2e5d5a Fixes NPE due to using wrong field. 2017-08-11 21:33:57 +02:00
fscan 3b58f5e8da fix me io port (#3019) 2017-08-09 10:39:07 +02:00
fscan 092afad4a5 Correctly detect redstone updates on all sides. (#3017) 2017-08-09 10:30:44 +02:00
Gunther De Wachter 6aa810d62a Re-add a missing piece of IC2 integration code.
This should fix a bunch of IC2 spam in the console and allow items to be charged in IC2 blocks.
2017-08-07 10:15:26 +02:00
Gunther De Wachter 41d98f9944 Fixed ME Chest visually not updating its cell state 2017-08-05 11:43:57 +02:00
Gunther De Wachter 1b198979fd Fixed export bus never speeding up. 2017-08-05 10:45:13 +02:00
tyra 8d5cc916e0 Adds improved tooltip to invalid encodedPattern (#2992)
* Adds improved tooltip to invalid encodedPattern

This also fixes that encodedPattern might be shown as valid,
even though one or more input or output item is missing.
2017-08-04 21:17:35 +02:00
Gunther De Wachter 5abb8bf886 Removed call to super in Crafting Terminal initialisation code. Fixes #2988 2017-08-04 20:28:11 +02:00
Gunther De Wachter 0bed78a144 Re-enabled JEI search integration in terminals. 2017-08-03 22:00:42 +02:00
fscan 30940e91ea InterfaceTerminal: Put into to cursor, not player hand (#2996) 2017-07-31 17:16:56 +02:00
fscan 0f9ac5fdda Fix Inscriber and Molecular Assembler (#2995)
* Fix inscriber
* Allow GUI extraction for Molecular Assembler
2017-07-31 16:06:39 +02:00
fscan 5e001d86cb Move model loading to the correct event. Fixes #2991 (#2994)
* Use the correct event for loading models.
* Introduce IModelRegistry to wrap the ModelLoader
2017-07-31 15:51:53 +02:00
fscan b13a338948 Fix/Remove storage/import/export bus IItemHandler caching (#2987)
* Fix storage/import/export bus IItemHandler caching
2017-07-31 15:51:01 +02:00
yueh 454404b0c1 Changed ItemGen to use IItemHandler 2017-07-30 20:17:23 +02:00
335 changed files with 3420 additions and 3931 deletions
+6 -3
View File
@@ -45,6 +45,12 @@ apply from: 'gradle/scripts/optional.gradle'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
// ensure everything uses UTF-8 and not some random codepage chosen by gradle
compileJava.options.encoding = 'UTF-8'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
version = aeversion + "-" + aechannel + "-" + aebuild
group = aegroup
archivesBaseName = aebasename
@@ -52,7 +58,6 @@ archivesBaseName = aebasename
// Add Coremod Manifest
jar {
manifest {
attributes 'FMLCorePluginContainsFMLMod': 'true'
attributes 'FMLAT': 'appeng_at.cfg'
}
@@ -68,8 +73,6 @@ jar {
}
minecraft {
coreMod = "appeng.coremod.AppEngCore"
version = minecraft_version + "-" + forge_version
replaceIn "AEConfig.java"
+7 -1
View File
@@ -21,6 +21,12 @@ hwyla_version=1.8.19-B33_1.12
#########################################################
jei_version=4.7.1.69
tesla_version=1.0.61
ic2_version=2.8.7-ex112
ic2_version=2.8.9-ex112
rf_version=2.0.0.1
top_version=1.12-1.4.8-2
#########################################################
# Deployment #
#########################################################
website_version=1.12.x
curse_versions=1.12,1.12.1
@@ -28,7 +28,6 @@ public enum TunnelType
{
ME, // Network Tunnel
IC2_POWER, // EU Tunnel
RF_POWER, // RF Tunnel
FE_POWER, // Forge Energy tunnel
REDSTONE, // Redstone Tunnel
FLUID, // Fluid Tunnel
@@ -38,7 +38,9 @@ public interface IParts
AEColoredItemDefinition cableGlass();
AEColoredItemDefinition cableDense();
AEColoredItemDefinition cableDenseCovered();
AEColoredItemDefinition cableDenseSmart();
AEColoredItemDefinition lumenCableSmart();
@@ -46,7 +48,7 @@ public interface IParts
AEColoredItemDefinition lumenCableGlass();
AEColoredItemDefinition lumenCableDense();
AEColoredItemDefinition lumenDenseCableSmart();
IItemDefinition quartzFiber();
@@ -80,8 +82,6 @@ public interface IParts
IItemDefinition p2PTunnelEU();
IItemDefinition p2PTunnelRF();
IItemDefinition p2PTunnelFE();
IItemDefinition p2PTunnelLight();
@@ -27,6 +27,7 @@ package appeng.api.implementations.items;
import net.minecraft.item.ItemStack;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.energy.IAEPowerStorage;
@@ -42,27 +43,27 @@ public interface IAEItemPowerStorage
*
* @return amount unable to be stored
*/
double injectAEPower( ItemStack is, double amt );
double injectAEPower( ItemStack stack, double amount, Actionable mode );
/**
* Attempt to extract power from the device, it will extract what it can and
* return it.
*
* @param amt to be extracted power from device
* @param amount to be extracted power from device
*
* @return what it could extract
*/
double extractAEPower( ItemStack is, double amt );
double extractAEPower( ItemStack stack, double amount, Actionable mode );
/**
* @return the current maximum power ( this can change :P )
*/
double getAEMaxPower( ItemStack is );
double getAEMaxPower( ItemStack stack );
/**
* @return the current AE Power Level, this may exceed getMEMaxPower()
*/
double getAECurrentPower( ItemStack is );
double getAECurrentPower( ItemStack stack );
/**
* Control the power flow by telling what the network can do, either add? or
@@ -70,5 +71,5 @@ public interface IAEItemPowerStorage
*
* @return access restriction of network
*/
AccessRestriction getPowerFlow( ItemStack is );
AccessRestriction getPowerFlow( ItemStack stack );
}
@@ -46,6 +46,11 @@ public enum AECableType
*/
SMART,
/**
* Smart Dense Cable, represents a tier 2 block that can carry 32 channels.
*/
DENSE_COVERED,
/**
* Smart Dense Cable, represents a tier 2 block that can carry 32 channels.
*/
@@ -55,6 +60,7 @@ public enum AECableType
GLASS,
COVERED,
SMART,
DENSE_COVERED,
DENSE_SMART
};
@@ -31,6 +31,7 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.PowerUnits;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.implementations.items.IAEItemPowerStorage;
@@ -66,67 +67,39 @@ public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEIte
.gui_localize( PowerUnits.AE.unlocalizedName ) + " - " + MessageFormat.format( " {0,number,#.##%} ", percent ) );
}
private double getMaxEnergyCapacity()
@Override
public double injectAEPower( final ItemStack is, double amount, Actionable mode )
{
final Block blockID = Block.getBlockFromItem( this );
final IBlockDefinition energyCell = Api.INSTANCE.definitions().blocks().energyCell();
return energyCell.maybeBlock().map( block ->
final double internalCurrentPower = this.getInternal( is );
final double internalMaxPower = this.getAEMaxPower( is );
final double required = internalMaxPower - internalCurrentPower;
final double overflow = Math.max( 0, amount - required );
if( mode == Actionable.MODULATE )
{
if( blockID == block )
{
return 200000;
}
else
{
return 8 * 200000;
}
} ).orElse( 0 );
final double toAdd = Math.min( required, amount );
final double newPowerStored = internalCurrentPower + toAdd;
this.setInternal( is, newPowerStored );
}
return overflow;
}
@Override
public double injectAEPower( final ItemStack is, double amt )
public double extractAEPower( final ItemStack is, double amount, Actionable mode )
{
double internalCurrentPower = this.getInternal( is );
final double internalMaxPower = this.getMaxEnergyCapacity();
internalCurrentPower += amt;
if( internalCurrentPower > internalMaxPower )
final double internalCurrentPower = this.getInternal( is );
final double fulfillable = Math.min( amount, internalCurrentPower );
if( mode == Actionable.MODULATE )
{
amt = internalCurrentPower - internalMaxPower;
internalCurrentPower = internalMaxPower;
this.setInternal( is, internalCurrentPower );
return amt;
final double newPowerStored = internalCurrentPower - fulfillable;
this.setInternal( is, newPowerStored );
}
this.setInternal( is, internalCurrentPower );
return 0;
}
private double getInternal( final ItemStack is )
{
final NBTTagCompound nbt = Platform.openNbtData( is );
return nbt.getDouble( "internalCurrentPower" );
}
private void setInternal( final ItemStack is, final double amt )
{
final NBTTagCompound nbt = Platform.openNbtData( is );
nbt.setDouble( "internalCurrentPower", amt );
}
@Override
public double extractAEPower( final ItemStack is, double amt )
{
double internalCurrentPower = this.getInternal( is );
if( internalCurrentPower > amt )
{
internalCurrentPower -= amt;
this.setInternal( is, internalCurrentPower );
return amt;
}
amt = internalCurrentPower;
this.setInternal( is, 0 );
return amt;
return fulfillable;
}
@Override
@@ -146,4 +119,34 @@ public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEIte
{
return AccessRestriction.WRITE;
}
private double getMaxEnergyCapacity()
{
final Block blockID = Block.getBlockFromItem( this );
final IBlockDefinition energyCell = Api.INSTANCE.definitions().blocks().energyCell();
return energyCell.maybeBlock().map( block ->
{
if( blockID == block )
{
return 200000;
}
else
{
return 8 * 200000;
}
} ).orElse( 0 );
}
private double getInternal( final ItemStack is )
{
final NBTTagCompound nbt = Platform.openNbtData( is );
return nbt.getDouble( "internalCurrentPower" );
}
private void setInternal( final ItemStack is, final double amt )
{
final NBTTagCompound nbt = Platform.openNbtData( is );
nbt.setDouble( "internalCurrentPower", amt );
}
}
@@ -101,6 +101,7 @@ public class BlockCableBus extends AEBaseTileBlock
// this will actually be overwritten later through setupTile and the
// combined layers
this.setTileEntity( TileCableBus.class );
this.useNeighborBrightness = true;
}
@Override
@@ -23,7 +23,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -42,11 +42,13 @@ import appeng.api.definitions.IBlockDefinition;
import appeng.block.AEBaseBlock;
import appeng.block.AEBaseItemBlock;
import appeng.block.AEBaseTileBlock;
import appeng.bootstrap.components.IBlockRegistrationComponent;
import appeng.bootstrap.components.IItemRegistrationComponent;
import appeng.bootstrap.components.IPreInitComponent;
import appeng.bootstrap.definitions.TileEntityDefinition;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.core.CreativeTab;
import appeng.core.Registration;
import appeng.core.features.AEFeature;
import appeng.core.features.ActivityState;
import appeng.core.features.BlockDefinition;
@@ -65,13 +67,7 @@ class BlockDefinitionBuilder implements IBlockBuilder
private final Supplier<? extends Block> blockSupplier;
private final List<BiConsumer<Block, Item>> preInitCallbacks = new ArrayList<>();
private final List<BiConsumer<Block, Item>> initCallbacks = new ArrayList<>();
private final List<BiConsumer<Block, Item>> modelRegCallbacks = new ArrayList<>();
private final List<BiConsumer<Block, Item>> postInitCallbacks = new ArrayList<>();
private final List<BiFunction<Block, Item, IBootstrapComponent>> bootstrapComponents = new ArrayList<>();
private final EnumSet<AEFeature> features = EnumSet.noneOf( AEFeature.class );
@@ -103,30 +99,9 @@ class BlockDefinitionBuilder implements IBlockBuilder
}
@Override
public BlockDefinitionBuilder preInit( BiConsumer<Block, Item> callback )
public BlockDefinitionBuilder bootstrap( BiFunction<Block, Item, IBootstrapComponent> callback )
{
this.preInitCallbacks.add( callback );
return this;
}
@Override
public BlockDefinitionBuilder init( BiConsumer<Block, Item> callback )
{
this.initCallbacks.add( callback );
return this;
}
@Override
public BlockDefinitionBuilder modelRegInit( BiConsumer<Block, Item> callback )
{
this.modelRegCallbacks.add( callback );
return this;
}
@Override
public BlockDefinitionBuilder postInit( BiConsumer<Block, Item> callback )
{
this.postInitCallbacks.add( callback );
this.bootstrapComponents.add( callback );
return this;
}
@@ -221,22 +196,16 @@ class BlockDefinitionBuilder implements IBlockBuilder
}
// Register the item and block with the game
this.factory.addPreInit( side ->
this.factory.addBootstrapComponent( (IBlockRegistrationComponent) ( side, registry ) -> registry.register( block ) );
if( item != null )
{
Registration.addBlockToRegister( block );
if( item != null )
{
Registration.addItemToRegister( item );
}
} );
this.factory.addBootstrapComponent( (IItemRegistrationComponent) ( side, registry ) -> registry.register( item ) );
}
block.setCreativeTab( this.creativeTab );
// Register all extra handlers
this.preInitCallbacks.forEach( consumer -> this.factory.addPreInit( side -> consumer.accept( block, item ) ) );
this.initCallbacks.forEach( consumer -> this.factory.addInit( side -> consumer.accept( block, item ) ) );
this.modelRegCallbacks.forEach( consumer -> this.factory.addModelReg( side -> consumer.accept( block, item ) ) );
this.postInitCallbacks.forEach( consumer -> this.factory.addPostInit( side -> consumer.accept( block, item ) ) );
this.bootstrapComponents.forEach( component -> this.factory.addBootstrapComponent( component.apply( block, item ) ) );
if( this.tileEntityDefinition != null && block instanceof AEBaseTileBlock )
{
@@ -268,7 +237,7 @@ class BlockDefinitionBuilder implements IBlockBuilder
if( block instanceof AEBaseTileBlock )
{
this.factory.addPreInit( side ->
this.factory.addBootstrapComponent( (IPreInitComponent) side ->
{
AEBaseTile.registerTileItem(
this.tileEntityDefinition == null ? ( (AEBaseTileBlock) block ).getTileEntityClass() : this.tileEntityDefinition.getTileEntityClass(),
@@ -110,13 +110,13 @@ class BlockRendering implements IBlockRendering
if( this.modelCustomizer != null )
{
factory.modelOverrideComponent.addOverride( block.getRegistryName().getResourcePath(), this.modelCustomizer );
factory.addModelOverride( block.getRegistryName().getResourcePath(), this.modelCustomizer );
}
else if( block instanceof AEBaseTileBlock )
{
// This is a default rotating model if the base-block uses an AE tile entity which exposes UP/FRONT as
// extended props
factory.modelOverrideComponent.addOverride( block.getRegistryName().getResourcePath(), ( l, m ) -> new AutoRotatingModel( m ) );
factory.addModelOverride( block.getRegistryName().getResourcePath(), ( l, m ) -> new AutoRotatingModel( m ) );
}
// TODO : 1.12
@@ -20,10 +20,18 @@ package appeng.bootstrap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Supplier;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.fml.relauncher.Side;
@@ -33,11 +41,7 @@ import appeng.api.definitions.IItemDefinition;
import appeng.api.util.AEColor;
import appeng.api.util.AEColoredItemDefinition;
import appeng.bootstrap.components.BuiltInModelComponent;
import appeng.bootstrap.components.InitComponent;
import appeng.bootstrap.components.ModelOverrideComponent;
import appeng.bootstrap.components.ModelRegComponent;
import appeng.bootstrap.components.PostInitComponent;
import appeng.bootstrap.components.PreInitComponent;
import appeng.bootstrap.components.TileEntityComponent;
import appeng.core.features.AEFeature;
import appeng.core.features.ActivityState;
@@ -51,10 +55,10 @@ public class FeatureFactory
private final AEFeature[] defaultFeatures;
private final List<IBootstrapComponent> bootstrapComponents;
private final Map<Class<? extends IBootstrapComponent>, List<IBootstrapComponent>> bootstrapComponents;
@SideOnly( Side.CLIENT )
ModelOverrideComponent modelOverrideComponent;
private ModelOverrideComponent modelOverrideComponent;
@SideOnly( Side.CLIENT )
private BuiltInModelComponent builtInModelComponent;
@@ -64,18 +68,18 @@ public class FeatureFactory
public FeatureFactory()
{
this.defaultFeatures = new AEFeature[] { AEFeature.CORE };
this.bootstrapComponents = new ArrayList<>();
this.bootstrapComponents = new HashMap<>();
this.tileEntityComponent = new TileEntityComponent();
this.bootstrapComponents.add( this.tileEntityComponent );
this.addBootstrapComponent( this.tileEntityComponent );
if( Platform.isClient() )
{
this.modelOverrideComponent = new ModelOverrideComponent();
this.bootstrapComponents.add( this.modelOverrideComponent );
this.addBootstrapComponent( this.modelOverrideComponent );
this.builtInModelComponent = new BuiltInModelComponent();
this.bootstrapComponents.add( this.builtInModelComponent );
this.addBootstrapComponent( this.builtInModelComponent );
}
}
@@ -123,29 +127,16 @@ public class FeatureFactory
return new FeatureFactory( this, features );
}
void addBootstrapComponent( IBootstrapComponent component )
public void addBootstrapComponent( IBootstrapComponent component )
{
this.bootstrapComponents.add( component );
Arrays.stream( component.getClass().getInterfaces() )
.filter( i -> IBootstrapComponent.class.isAssignableFrom( i ) )
.forEach( i -> this.addBootstrapComponent( (Class<? extends IBootstrapComponent>) i, component ) );
}
void addPreInit( PreInitComponent component )
private <T extends IBootstrapComponent> void addBootstrapComponent( Class<? extends IBootstrapComponent> eventType, T component )
{
this.bootstrapComponents.add( component );
}
void addInit( InitComponent component )
{
this.bootstrapComponents.add( component );
}
void addModelReg( ModelRegComponent component )
{
this.bootstrapComponents.add( component );
}
void addPostInit( PostInitComponent component )
{
this.bootstrapComponents.add( component );
bootstrapComponents.computeIfAbsent( eventType, c -> new ArrayList<IBootstrapComponent>() ).add( component );
}
@SideOnly( Side.CLIENT )
@@ -154,8 +145,14 @@ public class FeatureFactory
this.builtInModelComponent.addModel( path, model );
}
public List<IBootstrapComponent> getBootstrapComponents()
@SideOnly( Side.CLIENT )
void addModelOverride( String resourcePath, BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer )
{
return this.bootstrapComponents;
this.modelOverrideComponent.addOverride( resourcePath, customizer );
}
public <T extends IBootstrapComponent> Iterator<T> getBootstrapComponents( Class<T> eventType )
{
return (Iterator<T>) this.bootstrapComponents.getOrDefault( eventType, Collections.emptyList() ).iterator();
}
}
@@ -19,7 +19,7 @@
package appeng.bootstrap;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;
import net.minecraft.block.Block;
@@ -33,14 +33,7 @@ import appeng.core.features.AEFeature;
public interface IBlockBuilder
{
IBlockBuilder preInit( BiConsumer<Block, Item> callback );
IBlockBuilder init( BiConsumer<Block, Item> callback );
IBlockBuilder modelRegInit( BiConsumer<Block, Item> callback );
IBlockBuilder postInit( BiConsumer<Block, Item> callback );
IBlockBuilder bootstrap( BiFunction<Block, Item, IBootstrapComponent> component );
IBlockBuilder features( AEFeature... features );
@@ -19,28 +19,10 @@
package appeng.bootstrap;
import net.minecraftforge.fml.relauncher.Side;
/**
* Bootstrap components can be registered to take part in the various initialization phases of Forge.
* See the individual subclasses for a specific forge initalization event.
*/
public interface IBootstrapComponent
{
default void preInitialize( Side side )
{
}
default void modelReg( Side side )
{
}
default void initialize( Side side )
{
}
default void postInitialize( Side side )
{
}
}
@@ -19,7 +19,7 @@
package appeng.bootstrap;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import net.minecraft.creativetab.CreativeTabs;
@@ -36,12 +36,7 @@ import appeng.core.features.ItemDefinition;
*/
public interface IItemBuilder
{
IItemBuilder preInit( Consumer<Item> callback );
IItemBuilder init( Consumer<Item> callback );
IItemBuilder postInit( Consumer<Item> callback );
IItemBuilder bootstrap( Function<Item, IBootstrapComponent> component );
IItemBuilder features( AEFeature... features );
@@ -16,24 +16,24 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.rf;
package appeng.bootstrap;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
/**
* @author GuntherDW
*/
public class RFModule implements IIntegrationModule
public interface IModelRegistry
{
public RFModule()
{
IntegrationHelper.testClassExistence( this, cofh.redstoneflux.api.IEnergyContainerItem.class );
IntegrationHelper.testClassExistence( this, cofh.redstoneflux.api.IEnergyProvider.class );
IntegrationHelper.testClassExistence( this, cofh.redstoneflux.api.IEnergyConnection.class );
IntegrationHelper.testClassExistence( this, cofh.redstoneflux.api.IEnergyContainerItem.class );
}
void registerItemVariants( Item item, ResourceLocation... names );
void setCustomModelResourceLocation( Item item, int metadata, ModelResourceLocation model );
void setCustomMeshDefinition( Item item, ItemMeshDefinition meshDefinition );
void setCustomStateMapper( Block block, IStateMapper mapper );
}
@@ -23,7 +23,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import net.minecraft.block.BlockDispenser;
@@ -33,10 +33,11 @@ import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.bootstrap.components.IItemRegistrationComponent;
import appeng.bootstrap.components.IPostInitComponent;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.core.CreativeTab;
import appeng.core.Registration;
import appeng.core.features.AEFeature;
import appeng.core.features.ItemDefinition;
import appeng.util.Platform;
@@ -53,13 +54,7 @@ class ItemDefinitionBuilder implements IItemBuilder
private final EnumSet<AEFeature> features = EnumSet.noneOf( AEFeature.class );
private final List<Consumer<Item>> preInitCallbacks = new ArrayList<>();
private final List<Consumer<Item>> initCallbacks = new ArrayList<>();
private final List<Consumer<Item>> modelRegCallbacks = new ArrayList<>();
private final List<Consumer<Item>> postInitCallbacks = new ArrayList<>();
private final List<Function<Item, IBootstrapComponent>> boostrapComponents = new ArrayList<>();
private Supplier<IBehaviorDispenseItem> dispenserBehaviorSupplier;
@@ -80,23 +75,9 @@ class ItemDefinitionBuilder implements IItemBuilder
}
@Override
public ItemDefinitionBuilder preInit( Consumer<Item> callback )
public IItemBuilder bootstrap( Function<Item, IBootstrapComponent> component )
{
this.preInitCallbacks.add( callback );
return this;
}
@Override
public ItemDefinitionBuilder init( Consumer<Item> callback )
{
this.initCallbacks.add( callback );
return this;
}
@Override
public ItemDefinitionBuilder postInit( Consumer<Item> callback )
{
this.postInitCallbacks.add( callback );
this.boostrapComponents.add( component );
return this;
}
@@ -163,22 +144,19 @@ class ItemDefinitionBuilder implements IItemBuilder
item.setCreativeTab( this.creativeTab );
// Register all extra handlers
this.preInitCallbacks.forEach( consumer -> this.factory.addPreInit( side -> consumer.accept( item ) ) );
this.initCallbacks.forEach( consumer -> this.factory.addInit( side -> consumer.accept( item ) ) );
this.modelRegCallbacks.forEach( consumer -> this.factory.addModelReg( side -> consumer.accept( item ) ) );
this.postInitCallbacks.forEach( consumer -> this.factory.addPostInit( side -> consumer.accept( item ) ) );
this.boostrapComponents.forEach( component -> component.apply( item ) );
// Register custom dispenser behavior if requested
if( this.dispenserBehaviorSupplier != null )
{
this.factory.addPostInit( side ->
this.factory.addBootstrapComponent( (IPostInitComponent) side ->
{
IBehaviorDispenseItem behavior = this.dispenserBehaviorSupplier.get();
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject( item, behavior );
} );
}
this.factory.addPreInit( side -> Registration.addItemToRegister( item ) );
this.factory.addBootstrapComponent( (IItemRegistrationComponent) ( side, reg ) -> reg.register( item ) );
if( Platform.isClient() )
{
@@ -187,4 +165,5 @@ class ItemDefinitionBuilder implements IItemBuilder
return definition;
}
}
@@ -128,15 +128,13 @@ class ItemRendering implements IItemRendering
Block block = ( (ItemBlock) item ).getBlock();
// We can only do this once the blocks are actually registered...
StateMapperHelper helper = new StateMapperHelper( block.getRegistryName() );
StateMapperHelper helper = new StateMapperHelper( item.getRegistryName() );
model = helper.getModelResourceLocation( block.getDefaultState() );
}
else
{
model = new ModelResourceLocation( item.getRegistryName(), "inventory" );
resources.add( model );
}
factory.addBootstrapComponent( new ItemModelComponent( item, ImmutableMap.of( 0, model ) ) );
}
@@ -147,17 +145,12 @@ class ItemRendering implements IItemRendering
{
factory.addBootstrapComponent( new ItemVariantsComponent( item, resources ) );
}
else if( !this.itemModels.isEmpty() || this.itemMeshDefinition != null )
else if( this.itemMeshDefinition != null )
{
// Adding an empty variant list here will prevent Vanilla from trying to load the default item model in this
// case
factory.addBootstrapComponent( new ItemVariantsComponent( item, Collections.emptyList() ) );
}
else if( item instanceof ItemBlock )
{
// The default for block items is to register the block model
factory.addBootstrapComponent( new ItemVariantsComponent( item, Collections.emptyList() ) );
}
if( this.itemColor != null )
{
@@ -25,7 +25,7 @@ import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraftforge.fml.relauncher.Side;
public class BlockColorComponent implements InitComponent
public class BlockColorComponent implements IInitComponent
{
private final Block block;
@@ -33,7 +33,7 @@ import appeng.client.render.model.BuiltInModelLoader;
@SideOnly( Side.CLIENT )
public class BuiltInModelComponent implements PreInitComponent
public class BuiltInModelComponent implements IPreInitComponent
{
private final Map<String, IModel> builtInModels = new HashMap<>();
@@ -0,0 +1,16 @@
package appeng.bootstrap.components;
import net.minecraft.block.Block;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.registries.IForgeRegistry;
import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface IBlockRegistrationComponent extends IBootstrapComponent
{
void blockRegistration( Side side, IForgeRegistry<Block> blockRegistry );
}
@@ -25,10 +25,7 @@ import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface InitComponent extends IBootstrapComponent
public interface IInitComponent extends IBootstrapComponent
{
@Override
void initialize( Side side );
}
@@ -0,0 +1,16 @@
package appeng.bootstrap.components;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.registries.IForgeRegistry;
import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface IItemRegistrationComponent extends IBootstrapComponent
{
void itemRegistration( Side side, IForgeRegistry<Item> itemRegistry );
}
@@ -0,0 +1,36 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, 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.bootstrap.components;
import net.minecraftforge.fml.relauncher.Side;
import appeng.bootstrap.IBootstrapComponent;
import appeng.bootstrap.IModelRegistry;
/**
* @author GuntherDW
*/
@FunctionalInterface
public interface IModelRegistrationComponent extends IBootstrapComponent
{
void modelRegistration( Side side, IModelRegistry registry );
}
@@ -1,6 +1,6 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
* Copyright (c) 2013 - 2014, 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
@@ -16,19 +16,16 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.abstraction;
package appeng.bootstrap.components;
import appeng.integration.IIntegrationModule;
import net.minecraftforge.fml.relauncher.Side;
import appeng.bootstrap.IBootstrapComponent;
/**
* @author GuntherDW
*/
public interface IRF
@FunctionalInterface
public interface IOreDictComponent extends IBootstrapComponent
{
class Stub extends IIntegrationModule.Stub implements IRF
{
}
void oreRegistration( Side side );
}
@@ -25,9 +25,7 @@ import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface PostInitComponent extends IBootstrapComponent
public interface IPostInitComponent extends IBootstrapComponent
{
@Override
void postInitialize( Side side );
}
@@ -25,10 +25,7 @@ import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface PreInitComponent extends IBootstrapComponent
public interface IPreInitComponent extends IBootstrapComponent
{
@Override
void preInitialize( Side side );
}
@@ -0,0 +1,16 @@
package appeng.bootstrap.components;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.registries.IForgeRegistry;
import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface IRecipeRegistrationComponent extends IBootstrapComponent
{
void recipeRegistration( Side side, IForgeRegistry<IRecipe> recipeRegistry );
}
@@ -25,7 +25,7 @@ import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
public class ItemColorComponent implements InitComponent
public class ItemColorComponent implements IInitComponent
{
private final Item item;
@@ -21,17 +21,18 @@ package appeng.bootstrap.components;
import javax.annotation.Nonnull;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import appeng.bootstrap.IModelRegistry;
/**
* Registers a custom item mesh definition that can be used to dynamically determine the item model based on
* item stack properties.
*/
public class ItemMeshDefinitionComponent implements InitComponent
public class ItemMeshDefinitionComponent implements IModelRegistrationComponent
{
private final Item item;
@@ -45,8 +46,8 @@ public class ItemMeshDefinitionComponent implements InitComponent
}
@Override
public void initialize( Side side )
public void modelRegistration( Side side, IModelRegistry registry )
{
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( this.item, this.meshDefinition );
registry.setCustomMeshDefinition( this.item, this.meshDefinition );
}
}
@@ -23,18 +23,18 @@ import java.util.Map;
import javax.annotation.Nonnull;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemModelMesher;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import appeng.bootstrap.IModelRegistry;
/**
* Registers the models that should by used for an item, including the ability to
* distinguish by meta.
*/
public class ItemModelComponent implements InitComponent
public class ItemModelComponent implements IModelRegistrationComponent
{
private final Item item;
@@ -48,13 +48,11 @@ public class ItemModelComponent implements InitComponent
}
@Override
public void initialize( Side side )
public void modelRegistration( Side side, IModelRegistry registry )
{
ItemModelMesher itemMesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
this.modelsByMeta.forEach( ( meta, model ) ->
{
itemMesher.register( this.item, meta, model );
registry.setCustomModelResourceLocation( this.item, meta, model );
} );
}
@@ -21,15 +21,14 @@ package appeng.bootstrap.components;
import java.util.Collection;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import appeng.bootstrap.IBootstrapComponent;
import appeng.bootstrap.IModelRegistry;
public class ItemVariantsComponent implements IBootstrapComponent
public class ItemVariantsComponent implements IModelRegistrationComponent
{
private final Item item;
@@ -43,9 +42,9 @@ public class ItemVariantsComponent implements IBootstrapComponent
}
@Override
public void preInitialize( Side side )
public void modelRegistration( Side side, IModelRegistry registry )
{
ResourceLocation[] resourceArr = this.resources.toArray( new ResourceLocation[0] );
ModelBakery.registerItemVariants( this.item, resourceArr );
registry.registerItemVariants( this.item, resourceArr );
}
}
@@ -39,7 +39,7 @@ import net.minecraftforge.fml.relauncher.Side;
import appeng.core.AppEng;
public class ModelOverrideComponent implements PreInitComponent
public class ModelOverrideComponent implements IPreInitComponent
{
private static final ModelResourceLocation MODEL_MISSING = new ModelResourceLocation( "builtin/missing", "missing" );
@@ -1,21 +0,0 @@
package appeng.bootstrap.components;
import net.minecraftforge.fml.relauncher.Side;
import appeng.bootstrap.IBootstrapComponent;
/**
* @author GuntherDW
*/
@FunctionalInterface
public interface ModelRegComponent extends IBootstrapComponent
{
@Override
void modelReg( Side side );
}
@@ -24,14 +24,15 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import appeng.bootstrap.IModelRegistry;
/**
* Registers a custom state mapper for a given block.
*/
public class StateMapperComponent implements ModelRegComponent
public class StateMapperComponent implements IModelRegistrationComponent
{
private final Block block;
@@ -45,9 +46,9 @@ public class StateMapperComponent implements ModelRegComponent
}
@Override
public void modelReg( Side side )
public void modelRegistration( Side side, IModelRegistry registry )
{
ModelLoader.setCustomStateMapper( this.block, this.stateMapper );
registry.setCustomStateMapper( this.block, this.stateMapper );
if( this.stateMapper instanceof IResourceManagerReloadListener )
{
( (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager() )
@@ -32,7 +32,7 @@ import appeng.tile.AEBaseTile;
* @param <T>
*/
// public class TesrComponent<T extends AEBaseTile> implements ModelRegComponent
public class TesrComponent<T extends AEBaseTile> implements PreInitComponent
public class TesrComponent<T extends AEBaseTile> implements IPreInitComponent
{
private final Class<T> tileEntityClass;
@@ -15,7 +15,7 @@ import appeng.core.AppEng;
/**
* @author GuntherDW
*/
public class TileEntityComponent implements PreInitComponent
public class TileEntityComponent implements IPreInitComponent
{
private List<TileEntityDefinition> tileEntityDefinitions = new ArrayList<>();
@@ -62,7 +62,6 @@ import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketAssemblerAnimation;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.coremod.MissingCoreMod;
import appeng.entity.EntityFloatingItem;
import appeng.entity.EntityTinyTNTPrimed;
import appeng.entity.RenderFloatingItem;
@@ -241,12 +240,6 @@ public class ClientHelper extends ServerHelper
mc.world.markBlockRangeForRenderUpdate( x - range, y - range, z - range, x + range, y + range, z + range );
}
@Override
public void missingCoreMod()
{
throw new MissingCoreMod();
}
@SubscribeEvent
public void postPlayerRender( final RenderLivingEvent.Pre p )
{
@@ -455,7 +455,7 @@ public abstract class AEBaseGui extends GuiContainer
action = ( mouseButton == 1 ) ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
stack = ( (SlotME) slot ).getAEStack();
if( stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getShowCraftingLabel() )
if( stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getShowCraftingLabel() && player.inventory.getItemStack().isEmpty() )
{
action = InventoryAction.AUTO_CRAFT;
}
@@ -101,6 +101,9 @@ class CableBuilder
case SMART:
textureFolder = "parts/cable/smart/";
break;
case DENSE_COVERED:
textureFolder = "parts/cable/dense_covered/";
break;
case DENSE_SMART:
textureFolder = "parts/cable/dense_smart/";
break;
@@ -127,6 +130,7 @@ class CableBuilder
case SMART:
this.addCableCore( CableCoreType.COVERED, color, quadsOut );
break;
case DENSE_COVERED:
case DENSE_SMART:
this.addCableCore( CableCoreType.DENSE_SMART, color, quadsOut );
break;
@@ -448,7 +452,31 @@ class CableBuilder
addCoveredCableSizedCube( facing, distanceFromEdge, cubeBuilder );
}
public void addDenseConnection( EnumFacing facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, int channels, List<BakedQuad> quadsOut )
public void addDenseCoveredConnection( EnumFacing facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, List<BakedQuad> quadsOut )
{
// Dense cables only render their connections as dense if the adjacent blocks actually wants that
if( connectionType == AECableType.COVERED || connectionType == AECableType.SMART || connectionType == AECableType.GLASS )
{
this.addCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut );
return;
}
CubeBuilder cubeBuilder = new CubeBuilder( this.format, quadsOut );
// We render all faces except the one on the connection side
cubeBuilder.setDrawFaces( EnumSet.complementOf( EnumSet.of( facing ) ) );
TextureAtlasSprite texture = this.connectionTextures.get( AECableType.DENSE_COVERED ).get( cableColor );
cubeBuilder.setTexture( texture );
addDenseCableSizedCube( facing, cubeBuilder );
// Reset back to normal rendering for the rest
cubeBuilder.setRenderFullBright( false );
cubeBuilder.setTexture( texture );
}
public void addDenseSmartConnection( EnumFacing facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, int channels, List<BakedQuad> quadsOut )
{
// Dense cables only render their connections as dense if the adjacent blocks actually wants that
if( connectionType == AECableType.SMART )
@@ -456,7 +484,7 @@ class CableBuilder
this.addSmartConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut );
return;
}
else if( connectionType != AECableType.DENSE_SMART )
else if( connectionType == AECableType.COVERED || connectionType == AECableType.GLASS )
{
this.addCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut );
return;
@@ -495,7 +523,19 @@ class CableBuilder
}
public void addStraightDenseConnection( EnumFacing facing, AEColor cableColor, int channels, List<BakedQuad> quadsOut )
public void addStraightDenseCoveredConnection( EnumFacing facing, AEColor cableColor, List<BakedQuad> quadsOut )
{
CubeBuilder cubeBuilder = new CubeBuilder( this.format, quadsOut );
TextureAtlasSprite texture = this.connectionTextures.get( AECableType.DENSE_COVERED ).get( cableColor );
cubeBuilder.setTexture( texture );
setStraightCableUVs( cubeBuilder, facing, 5, 11 );
addStraightDenseCableSizedCube( facing, cubeBuilder );
}
public void addStraightDenseSmartConnection( EnumFacing facing, AEColor cableColor, int channels, List<BakedQuad> quadsOut )
{
CubeBuilder cubeBuilder = new CubeBuilder( this.format, quadsOut );
@@ -164,6 +164,8 @@ public class CableBusBakedModel implements IBakedModel
{
case GLASS:
return firstType == AECableType.GLASS && secondType == AECableType.GLASS;
case DENSE_COVERED:
return firstType == AECableType.DENSE_COVERED && secondType == AECableType.DENSE_COVERED;
case DENSE_SMART:
return firstType == AECableType.DENSE_SMART && secondType == AECableType.DENSE_SMART;
}
@@ -200,8 +202,11 @@ public class CableBusBakedModel implements IBakedModel
case SMART:
this.cableBuilder.addStraightSmartConnection( facing, cableColor, renderState.getChannelsOnSide().get( facing ), quadsOut );
break;
case DENSE_COVERED:
this.cableBuilder.addStraightDenseCoveredConnection( facing, cableColor, quadsOut );
break;
case DENSE_SMART:
this.cableBuilder.addStraightDenseConnection( facing, cableColor, renderState.getChannelsOnSide().get( facing ), quadsOut );
this.cableBuilder.addStraightDenseSmartConnection( facing, cableColor, renderState.getChannelsOnSide().get( facing ), quadsOut );
break;
}
@@ -228,6 +233,7 @@ public class CableBusBakedModel implements IBakedModel
case SMART:
this.cableBuilder.addConstrainedSmartConnection( facing, cableColor, distance, channels, quadsOut );
break;
case DENSE_COVERED:
case DENSE_SMART:
// Dense cables do not render connections to parts since none can be attached
break;
@@ -253,8 +259,11 @@ public class CableBusBakedModel implements IBakedModel
case SMART:
this.cableBuilder.addSmartConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut );
break;
case DENSE_COVERED:
this.cableBuilder.addDenseCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut );
break;
case DENSE_SMART:
this.cableBuilder.addDenseConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut );
this.cableBuilder.addDenseSmartConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut );
break;
}
}
@@ -55,6 +55,7 @@ public enum CableCoreType
result.put( AECableType.GLASS, CableCoreType.GLASS );
result.put( AECableType.COVERED, CableCoreType.COVERED );
result.put( AECableType.SMART, CableCoreType.COVERED );
result.put( AECableType.DENSE_COVERED, CableCoreType.DENSE_SMART );
result.put( AECableType.DENSE_SMART, CableCoreType.DENSE_SMART );
return ImmutableMap.copyOf( result );
@@ -227,7 +227,7 @@ class ItemEncodedPatternBakedModel implements IBakedModel
{
ItemEncodedPattern iep = (ItemEncodedPattern) stack.getItem();
ItemStack output = iep.getOutput( stack );
if( output != null )
if( !output.isEmpty() )
{
IBakedModel realModel = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel( output );
// Give the item model a chance to handle the overrides as well
@@ -828,11 +828,11 @@ public abstract class AEBaseContainer extends Container
if( action == InventoryAction.MOVE_REGION )
{
final List<Slot> from = new LinkedList<>();
final List<Slot> from = new ArrayList<>();
for( final Object j : this.inventorySlots )
{
if( j instanceof Slot && j.getClass() == s.getClass() )
if( j instanceof Slot && j.getClass() == s.getClass() && !( j instanceof SlotCraftingTerm ) )
{
from.add( (Slot) j );
}
@@ -86,7 +86,6 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
}
this.outputSlot.putStack( CraftingManager.findMatchingResult( ic, this.getPlayerInv().player.world ) );
super.onCraftMatrixChanged( inventory );
}
@Override
@@ -135,13 +135,13 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
{
final boolean matchA = ( top.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( top,
recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and...
( bot.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( bot,
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) );
( ( bot.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( bot,
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ) );
final boolean matchB = ( bot.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( bot,
recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and...
( top.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( top,
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) );
( ( top.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( top,
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ) );
if( matchA || matchB )
{
@@ -50,6 +50,7 @@ import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.AdaptorItemHandler;
import appeng.util.inv.WrapperCursorItemHandler;
import appeng.util.inv.WrapperFilteredItemHandler;
import appeng.util.inv.WrapperRangeItemHandler;
import appeng.util.inv.filter.IAEItemFilter;
@@ -207,7 +208,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
final ItemStack is = inv.server.getStackInSlot( slot );
final boolean hasItemInHand = !player.inventory.getItemStack().isEmpty();
final InventoryAdaptor playerHand = InventoryAdaptor.getAdaptor( player );
final InventoryAdaptor playerHand = new AdaptorItemHandler( new WrapperCursorItemHandler( player.inventory ) );
final IItemHandler theSlot = new WrapperFilteredItemHandler( new WrapperRangeItemHandler( inv.server, slot, slot + 1 ), new PatternSlotFilter() );
final InventoryAdaptor interfaceSlot = new AdaptorItemHandler( theSlot );
@@ -110,7 +110,7 @@ public class ContainerQuartzKnife extends AEBaseContainer
@Override
public ItemStack getStack()
{
final IItemHandler baseInv = getItemHandler();
final IItemHandler baseInv = this.getItemHandler();
final ItemStack input = baseInv.getStackInSlot( 0 );
if( input == ItemStack.EMPTY )
{
@@ -137,10 +137,10 @@ public class ContainerQuartzKnife extends AEBaseContainer
@Nonnull
public ItemStack decrStackSize( int amount )
{
ItemStack ret = getStack();
ItemStack ret = this.getStack();
if( !ret.isEmpty() )
{
makePlate();
this.makePlate();
}
return ret;
}
@@ -150,21 +150,21 @@ public class ContainerQuartzKnife extends AEBaseContainer
{
if( stack.isEmpty() )
{
makePlate();
this.makePlate();
}
}
private void makePlate()
{
if( !getItemHandler().extractItem( 0, 1, false ).isEmpty() )
if( !this.getItemHandler().extractItem( 0, 1, false ).isEmpty() )
{
final ItemStack item = ContainerQuartzKnife.this.toolInv.getItemStack();
item.damageItem( 1, getPlayerInv().player );
item.damageItem( 1, ContainerQuartzKnife.this.getPlayerInv().player );
if( item.getCount() == 0 )
{
getPlayerInv().mainInventory.add( getPlayerInv().currentItem, ItemStack.EMPTY );
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( getPlayerInv().player, item, null ) );
ContainerQuartzKnife.this.getPlayerInv().mainInventory.add( ContainerQuartzKnife.this.getPlayerInv().currentItem, ItemStack.EMPTY );
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( ContainerQuartzKnife.this.getPlayerInv().player, item, null ) );
}
}
}
@@ -79,7 +79,7 @@ public class AppEngSlot extends Slot
public void clearStack()
{
super.putStack( ItemStack.EMPTY );
ItemHandlerUtil.setStackInSlot( this.itemHandler, this.slotNumber, ItemStack.EMPTY );
}
@Override
@@ -112,7 +112,7 @@ public class AppEngSlot extends Slot
return this.getDisplayStack();
}
return this.itemHandler.getStackInSlot( index );
return this.itemHandler.getStackInSlot( this.index );
}
@Override
@@ -120,7 +120,7 @@ public class AppEngSlot extends Slot
{
if( this.isSlotEnabled() )
{
ItemHandlerUtil.setStackInSlot( this.itemHandler, index, stack );
ItemHandlerUtil.setStackInSlot( this.itemHandler, this.index, stack );
this.onSlotChanged();
if( this.getContainer() != null )
@@ -151,7 +151,7 @@ public class AppEngSlot extends Slot
@Override
public int getItemStackLimit( @Nonnull ItemStack stack )
{
return Math.min( getSlotStackLimit(), stack.getMaxStackSize() );
return Math.min( this.getSlotStackLimit(), stack.getMaxStackSize() );
}
@Override
@@ -159,7 +159,7 @@ public class AppEngSlot extends Slot
{
if( this.isSlotEnabled() )
{
return !this.itemHandler.extractItem( index, 1, true ).isEmpty();
return !this.itemHandler.extractItem( this.index, 1, true ).isEmpty();
}
return false;
}
@@ -168,7 +168,7 @@ public class AppEngSlot extends Slot
@Nonnull
public ItemStack decrStackSize( int amount )
{
return this.itemHandler.extractItem( index, amount, false );
return this.itemHandler.extractItem( this.index, amount, false );
}
@Override
@@ -191,7 +191,7 @@ public class AppEngSlot extends Slot
public ItemStack getDisplayStack()
{
return this.itemHandler.getStackInSlot( index );
return this.itemHandler.getStackInSlot( this.index );
}
public float getOpacityOfIcon()
+17 -11
View File
@@ -28,10 +28,11 @@ import javax.annotation.Nonnull;
import com.google.common.base.Stopwatch;
import com.google.common.collect.Lists;
import net.minecraft.world.DimensionType;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
@@ -55,6 +56,7 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.worlddata.WorldData;
import appeng.hooks.TickHandler;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.recipes.CustomRecipeConfig;
import appeng.recipes.CustomRecipeForgeConfiguration;
import appeng.server.AECommand;
@@ -66,7 +68,7 @@ import appeng.services.version.VersionCheckerConfig;
import appeng.util.Platform;
@Mod( modid = AppEng.MOD_ID, acceptedMinecraftVersions = "[1.12]", name = AppEng.MOD_NAME, version = AEConfig.VERSION, dependencies = AppEng.MOD_DEPENDENCIES, guiFactory = "appeng.client.gui.config.AEConfigGuiFactory" )
@Mod( modid = AppEng.MOD_ID, acceptedMinecraftVersions = "[1.12,1.12.1]", name = AppEng.MOD_NAME, version = AEConfig.VERSION, dependencies = AppEng.MOD_DEPENDENCIES, guiFactory = "appeng.client.gui.config.AEConfigGuiFactory" )
public final class AppEng
{
@SidedProxy( clientSide = "appeng.client.ClientHelper", serverSide = "appeng.server.ServerHelper", modId = AppEng.MOD_ID )
@@ -114,6 +116,7 @@ public final class AppEng
FMLCommonHandler.instance().registerCrashCallable( new ModCrashEnhancement( CrashInfo.MOD_VERSION ) );
this.registration = new Registration();
MinecraftForge.EVENT_BUS.register( this.registration );
}
@Nonnull
@@ -123,21 +126,19 @@ public final class AppEng
return INSTANCE;
}
@Nonnull
public final Registration getRegistration()
public Biome getStorageBiome()
{
return this.registration;
return this.registration.storageBiome;
}
public DimensionType getStorageDimensionType()
{
return this.registration.storageDimensionType;
}
@EventHandler
private void preInit( final FMLPreInitializationEvent event )
{
if( !Loader.isModLoaded( "appliedenergistics2-core" ) )
{
AppEng.proxy.missingCoreMod();
}
MinecraftForge.EVENT_BUS.register( this.registration );
final Stopwatch watch = Stopwatch.createStarted();
this.configDirectory = new File( event.getModConfigurationDirectory().getPath(), "AppliedEnergistics2" );
this.recipeDirectory = new File( this.configDirectory, "aerecipes" );
@@ -165,6 +166,11 @@ public final class AppEng
CreativeTabFacade.init();
}
for( final IntegrationType type : IntegrationType.values() )
{
IntegrationRegistry.INSTANCE.add( type );
}
this.registration.preInitialize( event );
if( Platform.isClient() )
@@ -62,6 +62,4 @@ public abstract class CommonHelper
public abstract void updateRenderMode( EntityPlayer player );
public abstract void missingCoreMod();
}
+83 -162
View File
@@ -20,9 +20,7 @@ package appeng.core;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Nonnull;
@@ -30,12 +28,16 @@ import javax.annotation.Nonnull;
import com.google.common.base.Preconditions;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.DimensionType;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
@@ -44,8 +46,8 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.RecipeSorter.Category;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.registries.IForgeRegistry;
import appeng.api.config.Upgrades;
@@ -66,6 +68,16 @@ import appeng.api.networking.spatial.ISpatialCache;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.networking.ticking.ITickManager;
import appeng.api.parts.IPartHelper;
import appeng.api.recipes.IRecipeHandler;
import appeng.bootstrap.IModelRegistry;
import appeng.bootstrap.components.IBlockRegistrationComponent;
import appeng.bootstrap.components.IInitComponent;
import appeng.bootstrap.components.IItemRegistrationComponent;
import appeng.bootstrap.components.IModelRegistrationComponent;
import appeng.bootstrap.components.IOreDictComponent;
import appeng.bootstrap.components.IPostInitComponent;
import appeng.bootstrap.components.IPreInitComponent;
import appeng.bootstrap.components.IRecipeRegistrationComponent;
import appeng.capabilities.Capabilities;
import appeng.core.features.AEFeature;
import appeng.core.features.registries.P2PTunnelRegistry;
@@ -95,8 +107,6 @@ import appeng.recipes.CustomRecipeConfig;
import appeng.recipes.RecipeHandler;
import appeng.recipes.game.DisassembleRecipe;
import appeng.recipes.game.FacadeRecipe;
import appeng.recipes.game.ShapedRecipe;
import appeng.recipes.game.ShapelessRecipe;
import appeng.recipes.handlers.Crusher;
import appeng.recipes.handlers.Grind;
import appeng.recipes.handlers.HCCrusher;
@@ -106,8 +116,6 @@ import appeng.recipes.handlers.MekCrusher;
import appeng.recipes.handlers.MekEnrichment;
import appeng.recipes.handlers.Press;
import appeng.recipes.handlers.Pulverizer;
import appeng.recipes.handlers.Shaped;
import appeng.recipes.handlers.Shapeless;
import appeng.recipes.handlers.Smelt;
import appeng.recipes.ores.OreDictionaryHandler;
import appeng.spatial.BiomeGenStorage;
@@ -117,16 +125,11 @@ import appeng.worldgen.MeteoriteWorldGen;
import appeng.worldgen.QuartzWorldGen;
public final class Registration
final class Registration
{
private final RecipeHandler recipeHandler;
private DimensionType storageDimensionType;
private Biome storageBiome;
DimensionType storageDimensionType;
Biome storageBiome;
// TODO : 1.12 Improve
private static List<Block> blocksToRegister = new ArrayList<>();
private static List<Item> itemsToRegister = new ArrayList<>();
private static List<IRecipe> recipesToRegister = new ArrayList<>();
private File recipeDirectory;
private CustomRecipeConfig customRecipeConfig;
@@ -136,68 +139,24 @@ public final class Registration
this.customRecipeConfig = f2;
}
Registration()
{
this.recipeHandler = new RecipeHandler();
}
public Biome getStorageBiome()
{
return this.storageBiome;
}
public static void addBlockToRegister( Block b )
{
if( blocksToRegister == null )
{
throw new IllegalStateException( "Past the registration phase already!" );
}
blocksToRegister.add( b );
}
public static void addRecipeToRegister( IRecipe r )
{
if( recipesToRegister == null )
{
throw new IllegalStateException( "Past the registration phase already!" );
}
recipesToRegister.add( r );
}
public static void addItemToRegister( Item i )
{
if( itemsToRegister == null )
{
throw new IllegalStateException( "Past the registration phase already!" );
}
itemsToRegister.add( i );
}
public DimensionType getStorageDimensionType()
{
return this.storageDimensionType;
}
void preInitialize( final FMLPreInitializationEvent event )
{
// this.registerSpatial( false );
Capabilities.register();
final Api api = Api.INSTANCE;
final IRecipeHandlerRegistry recipeRegistry = api.registries().recipes();
this.registerCraftHandlers( recipeRegistry );
RecipeSorter.register( "AE2-Facade", FacadeRecipe.class, Category.SHAPED, "" );
RecipeSorter.register( "AE2-Shaped", ShapedRecipe.class, Category.SHAPED, "" );
RecipeSorter.register( "AE2-Shapeless", ShapelessRecipe.class, Category.SHAPELESS, "" );
// RecipeSorter.register( "AE2-Facade", FacadeRecipe.class, Category.SHAPED, "" );
// RecipeSorter.register( "AE2-Shaped", ShapedRecipe.class, Category.SHAPED, "" );
// RecipeSorter.register( "AE2-Shapeless", ShapelessRecipe.class, Category.SHAPELESS, "" );
MinecraftForge.EVENT_BUS.register( OreDictionaryHandler.INSTANCE );
ApiDefinitions definitions = api.definitions();
// Register all detected handlers and features (items, blocks) in pre-init
definitions.getRegistry().getBootstrapComponents().forEach( b -> b.preInitialize( event.getSide() ) );
// Register
definitions.getRegistry().getBootstrapComponents( IPreInitComponent.class ).forEachRemaining( b -> b.preInitialize( event.getSide() ) );
}
private void registerSpatial( final boolean force, IForgeRegistry<Biome> registry )
@@ -211,34 +170,11 @@ public final class Registration
if( this.storageBiome == null )
{
// if( force && config.getStorageBiomeID() == -1 )
// {
// config.setStorageBiomeID( Platform.findEmpty( Biome.REGISTRY, 0, 256 ) );
// if( config.getStorageBiomeID() == -1 )
// {
// throw new IllegalStateException( "Biome Array is full, please free up some Biome ID's or disable
// spatial." );
// }
//
// this.storageBiome = new BiomeGenStorage();
// Biome.registerBiome( config.getStorageBiomeID(), "appliedenergistics2:storage_biome", this.storageBiome
// );
// config.save();
// }
//
// if( !force && config.getStorageBiomeID() != -1 )
// {
// this.storageBiome = new BiomeGenStorage();
// Biome.registerBiome( config.getStorageBiomeID(), "appliedenergistics2:storage_biome", this.storageBiome
// );
// }
// TODO: 1.12, are modders allowed to even touch the ID's any more?
this.storageBiome = new BiomeGenStorage();
registry.register( this.storageBiome.setRegistryName( "appliedenergistics2:storage_biome" ) );
}
registry.register( this.storageBiome.setRegistryName( "appliedenergistics2:storage_biome" ) );
if( config.getStorageProviderID() != -1 )
{
this.storageDimensionType = DimensionType.register( "Storage Cell", "_cell", config.getStorageProviderID(), StorageWorldProvider.class, false );
@@ -280,9 +216,6 @@ public final class Registration
registry.addNewCraftHandler( "smelt", Smelt.class );
registry.addNewCraftHandler( "inscribe", Inscribe.class );
registry.addNewCraftHandler( "press", Press.class );
registry.addNewCraftHandler( "shaped", Shaped.class );
registry.addNewCraftHandler( "shapeless", Shapeless.class );
}
public void initialize( @Nonnull final FMLInitializationEvent event, @Nonnull final File recipeDirectory, @Nonnull final CustomRecipeConfig customRecipeConfig )
@@ -297,7 +230,9 @@ public final class Registration
final IRegistryContainer registries = api.registries();
ApiDefinitions definitions = api.definitions();
definitions.getRegistry().getBootstrapComponents().forEach( b -> b.initialize( event.getSide() ) );
definitions.getRegistry().getBootstrapComponents( IOreDictComponent.class ).forEachRemaining( b -> b.oreRegistration( event.getSide() ) );
definitions.getRegistry().getBootstrapComponents( IInitComponent.class ).forEachRemaining( b -> b.initialize( event.getSide() ) );
//
// // Perform ore camouflage!
// ItemMaterial.instance.makeUnique();
@@ -305,22 +240,6 @@ public final class Registration
// final Runnable recipeLoader = new RecipeLoader( recipeDirectory, customRecipeConfig, this.recipeHandler );
// recipeLoader.run();
if( Integrations.ic2().isEnabled() )
{
partHelper.registerNewLayer( "appeng.parts.layers.LayerIEnergySink", "ic2.api.energy.tile.IEnergySink" );
partHelper.registerNewLayer( "appeng.parts.layers.LayerIEnergySource", "ic2.api.energy.tile.IEnergySource" );
}
if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.RF ) )
{
partHelper.registerNewLayer( "appeng.parts.layers.LayerIEnergyHandler", "cofh.redstoneflux.api.IEnergyReceiver" );
}
// if (IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.RF)) {
// partHelper.registerNewLayer("appeng.parts.layers.LayerIEnergyStorager",
// "net.minecraftforge.common.capabilities.ICapabilityProvider");
// }
//
// if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.OpenComputers ) )
// {
// partHelper.registerNewLayer( "appeng.parts.layers.LayerSidedEnvironment",
@@ -356,9 +275,6 @@ public final class Registration
registries.matterCannon().registerAmmo( ammoStack, weight );
} );
// TODO : 1.12 This is way too late for recipes
// this.recipeHandler.injectRecipes();
final PlayerStatsRegistration registration = new PlayerStatsRegistration( MinecraftForge.EVENT_BUS, AEConfig.instance() );
registration.registerAchievementHandlers();
registration.registerAchievements();
@@ -367,44 +283,36 @@ public final class Registration
@SubscribeEvent
public void registerBiomes( RegistryEvent.Register<Biome> event )
{
IForgeRegistry<Biome> registry = event.getRegistry();
final IForgeRegistry<Biome> registry = event.getRegistry();
this.registerSpatial( false, registry );
}
@SubscribeEvent
@SideOnly( Side.CLIENT )
public void modelRegistryEvent( ModelRegistryEvent event )
{
final Api api = Api.INSTANCE;
final IPartHelper partHelper = api.partHelper();
final IRegistryContainer registries = api.registries();
ApiDefinitions definitions = api.definitions();
definitions.getRegistry().getBootstrapComponents().forEach( b -> b.modelReg( FMLCommonHandler.instance().getEffectiveSide() ) );
final ApiDefinitions definitions = Api.INSTANCE.definitions();
final IModelRegistry registry = new ModelLoaderWrapper();
final Side side = FMLCommonHandler.instance().getEffectiveSide();
definitions.getRegistry().getBootstrapComponents( IModelRegistrationComponent.class ).forEachRemaining( b -> b.modelRegistration( side, registry ) );
}
@SubscribeEvent
public void registerBlocks( RegistryEvent.Register<Block> event )
{
IForgeRegistry<Block> registry = event.getRegistry();
// TODO : 1.12 Improve
for( Block b : blocksToRegister )
{
registry.register( b );
}
blocksToRegister = null;
final IForgeRegistry<Block> registry = event.getRegistry();
final ApiDefinitions definitions = Api.INSTANCE.definitions();
final Side side = FMLCommonHandler.instance().getEffectiveSide();
definitions.getRegistry().getBootstrapComponents( IBlockRegistrationComponent.class ).forEachRemaining( b -> b.blockRegistration( side, registry ) );
}
@SubscribeEvent
public void registerItems( RegistryEvent.Register<Item> event )
{
IForgeRegistry<Item> registry = event.getRegistry();
// TODO : 1.12 Improve
for( Item i : itemsToRegister )
{
registry.register( i );
}
itemsToRegister = null;
final IForgeRegistry<Item> registry = event.getRegistry();
final ApiDefinitions definitions = Api.INSTANCE.definitions();
final Side side = FMLCommonHandler.instance().getEffectiveSide();
definitions.getRegistry().getBootstrapComponents( IItemRegistrationComponent.class ).forEachRemaining( b -> b.itemRegistration( side, registry ) );
}
@SubscribeEvent
@@ -414,20 +322,15 @@ public final class Registration
final Api api = Api.INSTANCE;
final ApiDefinitions definitions = api.definitions();
final Side side = FMLCommonHandler.instance().getEffectiveSide();
// Perform ore camouflage!
ItemMaterial.instance.makeUnique();
final Runnable recipeLoader = new RecipeLoader( this.recipeDirectory, this.customRecipeConfig, this.recipeHandler );
recipeLoader.run();
this.recipeHandler.injectRecipes();
if( AEConfig.instance().isFeatureEnabled( AEFeature.ENABLE_DISASSEMBLY_CRAFTING ) )
{
DisassembleRecipe r = new DisassembleRecipe();
// TODO : 1.12 Improve
addRecipeToRegister( r.setRegistryName( AppEng.MOD_ID.toLowerCase(), "disassemble" ) );
registry.register( r.setRegistryName( AppEng.MOD_ID.toLowerCase(), "disassemble" ) );
// RecipeSorter.register( "appliedenergistics2:disassemble", DisassembleRecipe.class, Category.SHAPELESS,
// "after:minecraft:shapeless" );
}
@@ -436,35 +339,24 @@ public final class Registration
{
definitions.items().facade().maybeItem().ifPresent( facadeItem ->
{
// TODO : 1.12 Improve
FacadeRecipe f = new FacadeRecipe( (ItemFacade) facadeItem );
addRecipeToRegister( f.setRegistryName( AppEng.MOD_ID.toLowerCase(), "facade" ) );
registry.register( f.setRegistryName( AppEng.MOD_ID.toLowerCase(), "facade" ) );
// RecipeSorter.register( "appliedenergistics2:facade", FacadeRecipe.class, Category.SHAPED,
// "after:minecraft:shaped" );
} );
}
int x = 0;
// TODO : 1.12 Improve
for( IRecipe r : recipesToRegister )
{
// TODO : 1.12 *really* improve.
// Move to json where possible?
if( r.getRegistryName() == null )
{
r.setRegistryName( new ResourceLocation( AppEng.MOD_ID.toLowerCase(), "recipe_" + x ) );
x++;
}
registry.register( r );
}
recipesToRegister = null;
definitions.getRegistry().getBootstrapComponents( IRecipeRegistrationComponent.class ).forEachRemaining( b -> b.recipeRegistration( side, registry ) );
// load machine recipes
final IRecipeHandler recipeHandler = new RecipeHandler();
final Runnable recipeLoader = new RecipeLoader( this.recipeDirectory, this.customRecipeConfig, recipeHandler );
recipeLoader.run();
recipeHandler.injectRecipes();
}
void postInit( final FMLPostInitializationEvent event )
{
// TODO : 1.12 Improve
final IRegistryContainer registries = Api.INSTANCE.registries();
ApiDefinitions definitions = Api.INSTANCE.definitions();
final IParts parts = definitions.parts();
@@ -478,7 +370,7 @@ public final class Registration
PlayerMessages.values();
GuiText.values();
definitions.getRegistry().getBootstrapComponents().forEach( b -> b.postInitialize( event.getSide() ) );
definitions.getRegistry().getBootstrapComponents( IPostInitComponent.class ).forEachRemaining( b -> b.postInitialize( event.getSide() ) );
// Interface
Upgrades.CRAFTING.registerItem( parts.iface(), 1 );
@@ -554,7 +446,7 @@ public final class Registration
if( AEConfig.instance().isFeatureEnabled( AEFeature.VILLAGER_TRADING ) )
{
// TODO: VILLAGER TRADING
// VillagerRegistry.instance().getRegisteredVillagers()..registerVillageTradeHandler( 3, new AETrading() );
// VillagerRegistry.instance().getRegisteredVillagers().registerVillageTradeHandler( 3, new AETrading() );
}
if( AEConfig.instance().isFeatureEnabled( AEFeature.CERTUS_QUARTZ_WORLD_GEN ) )
@@ -628,4 +520,33 @@ public final class Registration
*/
OreDictionaryHandler.INSTANCE.bakeRecipes();
}
private static class ModelLoaderWrapper implements IModelRegistry
{
@Override
public void registerItemVariants( Item item, ResourceLocation... names )
{
ModelLoader.registerItemVariants( item, names );
}
@Override
public void setCustomModelResourceLocation( Item item, int metadata, ModelResourceLocation model )
{
ModelLoader.setCustomModelResourceLocation( item, metadata, model );
}
@Override
public void setCustomMeshDefinition( Item item, ItemMeshDefinition meshDefinition )
{
ModelLoader.setCustomMeshDefinition( item, meshDefinition );
}
@Override
public void setCustomStateMapper( Block block, IStateMapper mapper )
{
ModelLoader.setCustomStateMapper( block, mapper );
}
}
}
@@ -93,6 +93,9 @@ import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.FeatureFactory;
import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering;
import appeng.bootstrap.components.IOreDictComponent;
import appeng.bootstrap.components.IPostInitComponent;
import appeng.bootstrap.components.IPreInitComponent;
import appeng.bootstrap.definitions.TileEntityDefinition;
import appeng.client.render.crafting.CraftingCubeRendering;
import appeng.client.render.model.GlassModel;
@@ -239,17 +242,12 @@ public final class ApiBlocks implements IBlocks
// this.quartzOre = new BlockDefinition( "ore.quartz", new OreQuartz() );
this.quartzOre = registry.block( "quartz_ore", BlockQuartzOre::new )
.features( AEFeature.CERTUS_ORE )
.postInit( ( block, item ) ->
{
OreDictionary.registerOre( "oreCertusQuartz", new ItemStack( block ) );
} )
.bootstrap( ( block, item ) -> (IOreDictComponent) side -> OreDictionary.registerOre( "oreCertusQuartz", new ItemStack( block ) ) )
.build();
this.quartzOreCharged = registry.block( "charged_quartz_ore", BlockChargedQuartzOre::new )
.features( AEFeature.CERTUS_ORE, AEFeature.CHARGED_CERTUS_ORE )
.postInit( ( block, item ) ->
{
OreDictionary.registerOre( "oreCertusQuartz", new ItemStack( block ) );
} )
.useCustomItemModel()
.bootstrap( ( block, item ) -> (IOreDictComponent) side -> OreDictionary.registerOre( "oreCertusQuartz", new ItemStack( block ) ) )
.build();
this.matrixFrame = registry.block( "matrix_frame", BlockMatrixFrame::new ).features( AEFeature.SPATIAL_IO ).build();
@@ -308,6 +306,7 @@ public final class ApiBlocks implements IBlocks
.features( AEFeature.GRIND_STONE )
.tileEntity( new TileEntityDefinition( TileCrank.class ) )
.rendering( new CrankRendering() )
.useCustomItemModel()
.build();
this.inscriber = registry.block( "inscriber", BlockInscriber::new )
.features( AEFeature.INSCRIBER )
@@ -334,10 +333,8 @@ public final class ApiBlocks implements IBlocks
.build();
this.tinyTNT = registry.block( "tiny_tnt", BlockTinyTNT::new )
.features( AEFeature.TINY_TNT )
.postInit( ( block, item ) ->
{
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject( item, new DispenserBehaviorTinyTNT() );
} )
.bootstrap( ( block, item ) -> (IPreInitComponent) side -> BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject( item,
new DispenserBehaviorTinyTNT() ) )
.build();
this.securityStation = registry.block( "security_station", BlockSecurityStation::new )
.features( AEFeature.SECURITY )
@@ -424,7 +421,6 @@ public final class ApiBlocks implements IBlocks
.build();
this.energyCellCreative = registry.block( "creative_energy_cell", BlockCreativeEnergyCell::new )
.features( AEFeature.CREATIVE )
.item( AEBaseItemBlockChargeable::new )
.tileEntity( new TileEntityDefinition( TileCreativeEnergyCell.class ) )
.build();
@@ -497,10 +493,8 @@ public final class ApiBlocks implements IBlocks
.rendering( new CableBusRendering( partModels ) )
// (handled in BlockCableBus.java and its setupTile())
// .tileEntity( TileCableBus.class )
.postInit( ( block, item ) ->
{
( (BlockCableBus) block ).setupTile();
} )
// TODO: why the custom registration?
.bootstrap( ( block, item ) -> (IPostInitComponent) side -> ( (BlockCableBus) block ).setupTile() )
.build();
this.skyStoneSlab = makeSlab( "sky_stone_slab", "sky_stone_double_slab", registry, this.skyStoneBlock() );
@@ -42,7 +42,8 @@ public final class ApiParts implements IParts
private final AEColoredItemDefinition cableSmart;
private final AEColoredItemDefinition cableCovered;
private final AEColoredItemDefinition cableGlass;
private final AEColoredItemDefinition cableDense;
private final AEColoredItemDefinition cableDenseCovered;
private final AEColoredItemDefinition cableDenseSmart;
// private final AEColoredItemDefinition lumenCableSmart;
// private final AEColoredItemDefinition lumenCableCovered;
// private final AEColoredItemDefinition lumenCableGlass;
@@ -63,7 +64,6 @@ public final class ApiParts implements IParts
private final IItemDefinition p2PTunnelItems;
private final IItemDefinition p2PTunnelFluids;
private final IItemDefinition p2PTunnelEU;
private final IItemDefinition p2PTunnelRF;
private final IItemDefinition p2PTunnelFE;
private final IItemDefinition p2PTunnelLight;
// private final IItemDefinition p2PTunnelOpenComputers;
@@ -94,7 +94,8 @@ public final class ApiParts implements IParts
this.cableSmart = constructColoredDefinition( itemPart, PartType.CABLE_SMART );
this.cableCovered = constructColoredDefinition( itemPart, PartType.CABLE_COVERED );
this.cableGlass = constructColoredDefinition( itemPart, PartType.CABLE_GLASS );
this.cableDense = constructColoredDefinition( itemPart, PartType.CABLE_DENSE_SMART );
this.cableDenseCovered = constructColoredDefinition( itemPart, PartType.CABLE_DENSE_COVERED );
this.cableDenseSmart = constructColoredDefinition( itemPart, PartType.CABLE_DENSE_SMART );
// this.lumenCableSmart = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
// this.lumenCableCovered = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
// this.lumenCableGlass = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
@@ -116,7 +117,6 @@ public final class ApiParts implements IParts
this.p2PTunnelItems = new DamagedItemDefinition( "part.tunnel.item", itemPart.createPart( PartType.P2P_TUNNEL_ITEMS ) );
this.p2PTunnelFluids = new DamagedItemDefinition( "part.tunnel.fluid", itemPart.createPart( PartType.P2P_TUNNEL_FLUIDS ) );
this.p2PTunnelEU = new DamagedItemDefinition( "part.tunnel.eu", itemPart.createPart( PartType.P2P_TUNNEL_IC2 ) );
this.p2PTunnelRF = new DamagedItemDefinition( "part.tunnel.rf", itemPart.createPart( PartType.P2P_TUNNEL_RF ) );
this.p2PTunnelFE = new DamagedItemDefinition( "part.tunnel.fe", itemPart.createPart( PartType.P2P_TUNNEL_FE ) );
this.p2PTunnelLight = new DamagedItemDefinition( "part.tunnel.light", itemPart.createPart( PartType.P2P_TUNNEL_LIGHT ) );
// this.p2PTunnelOpenComputers = new DamagedItemDefinition( itemMultiPart.createPart(
@@ -166,9 +166,15 @@ public final class ApiParts implements IParts
}
@Override
public AEColoredItemDefinition cableDense()
public AEColoredItemDefinition cableDenseCovered()
{
return this.cableDense;
return this.cableDenseCovered;
}
@Override
public AEColoredItemDefinition cableDenseSmart()
{
return this.cableDenseSmart;
}
@Override
@@ -193,7 +199,7 @@ public final class ApiParts implements IParts
}
@Override
public AEColoredItemDefinition lumenCableDense()
public AEColoredItemDefinition lumenDenseCableSmart()
{
throw new MissingDefinition( "Lumen Dense Cable has yet to be implemented." );
// return this.lumenCableDense;
@@ -295,12 +301,6 @@ public final class ApiParts implements IParts
return this.p2PTunnelEU;
}
@Override
public IItemDefinition p2PTunnelRF()
{
return this.p2PTunnelRF;
}
@Override
public IItemDefinition p2PTunnelFE()
{
@@ -113,7 +113,6 @@ public enum AEFeature
DENSE_ENERGY_CELLS( "DenseEnergyCells", Constants.CATEGORY_HIGHER_CAPACITY ),
DENSE_CABLES( "DenseCables", Constants.CATEGORY_HIGHER_CAPACITY ),
P2P_TUNNEL_RF( "P2PTunnelRF", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_ME( "P2PTunnelME", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_ITEMS( "P2PTunnelItems", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_REDSTONE( "P2PTunnelRedstone", Constants.CATEGORY_P2P_TUNNELS ),
@@ -73,22 +73,12 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
this.addNewAttunement( blocks.energyCell(), TunnelType.FE_POWER );
this.addNewAttunement( blocks.energyCellCreative(), TunnelType.FE_POWER );
/**
* RF tunnel items
*/
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 0 ), TunnelType.RF_POWER ); // leadstone
// fluxduct
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 1 ), TunnelType.RF_POWER ); // hardened
// fluxduct
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 2 ), TunnelType.RF_POWER ); // redstone
// fluxduct
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 3 ), TunnelType.RF_POWER ); // signalum
// fluxduct
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 4 ), TunnelType.RF_POWER ); // resonant
// fluxduct
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 5 ), TunnelType.RF_POWER ); // cryo-stabilized
// fluxduct
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 0 ), TunnelType.FE_POWER );
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 1 ), TunnelType.FE_POWER );
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 2 ), TunnelType.FE_POWER );
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 3 ), TunnelType.FE_POWER );
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 4 ), TunnelType.FE_POWER );
this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 5 ), TunnelType.FE_POWER );
/**
* EU tunnel items
@@ -167,22 +157,22 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
this.addNewAttunement( parts.cableGlass().stack( c, 1 ), TunnelType.ME );
this.addNewAttunement( parts.cableCovered().stack( c, 1 ), TunnelType.ME );
this.addNewAttunement( parts.cableSmart().stack( c, 1 ), TunnelType.ME );
this.addNewAttunement( parts.cableDense().stack( c, 1 ), TunnelType.ME );
this.addNewAttunement( parts.cableDenseSmart().stack( c, 1 ), TunnelType.ME );
}
/**
* attune based on the ItemStack's modId
*/
this.addNewAttunement( "thermaldynamics", TunnelType.RF_POWER );
this.addNewAttunement( "thermalexpansion", TunnelType.RF_POWER );
this.addNewAttunement( "thermalfoundation", TunnelType.RF_POWER );
this.addNewAttunement( "thermaldynamics", TunnelType.FE_POWER );
this.addNewAttunement( "thermalexpansion", TunnelType.FE_POWER );
this.addNewAttunement( "thermalfoundation", TunnelType.FE_POWER );
// TODO: Remove when confirmed that the official 1.12 version of EnderIO will support FE.
this.addNewAttunement( "enderio", TunnelType.RF_POWER );
this.addNewAttunement( "enderio", TunnelType.FE_POWER );
// TODO: Remove when confirmed that the official 1.12 version of Mekanism will support FE.
this.addNewAttunement( "mekanism", TunnelType.RF_POWER );
this.addNewAttunement( "mekanism", TunnelType.FE_POWER );
// TODO: Remove when support for RFTools' Powercells support is added
this.addNewAttunement( "rftools", TunnelType.RF_POWER );
this.addNewAttunement( "rftools", TunnelType.FE_POWER );
this.addNewAttunement( "ic2", TunnelType.IC2_POWER );
}
@@ -89,7 +89,6 @@ public enum GuiText
FluidTunnel,
OCTunnel,
LightTunnel,
RFTunnel,
FETunnel,
PressureTunnel,
@@ -80,7 +80,7 @@ public enum Achievements
Networking2( 4, 0, AEApi.instance().definitions().parts().cableSmart(), AchievementType.Custom ),
// done
Networking3( 4, 2, AEApi.instance().definitions().parts().cableDense(), AchievementType.Custom ),
Networking3( 4, 2, AEApi.instance().definitions().parts().cableDenseSmart(), AchievementType.Custom ),
// done
P2P( 2, -2, AEApi.instance().definitions().parts().p2PTunnelME(), AchievementType.Craft ),
@@ -62,7 +62,7 @@ public class PacketNewStorageDimension extends AppEngPacket
{
try
{
DimensionManager.registerDimension( this.newDim, AppEng.instance().getRegistration().getStorageDimensionType() );
DimensionManager.registerDimension( this.newDim, AppEng.instance().getStorageDimensionType() );
}
catch( final IllegalArgumentException iae )
{
@@ -88,7 +88,7 @@ final class DimensionData implements IWorldDimensionData, IOnWorldStartable, IOn
{
for( final Integer storageCellDimID : this.storageCellDimensionIDs )
{
DimensionManager.registerDimension( storageCellDimID, AppEng.instance().getRegistration().getStorageDimensionType() );
DimensionManager.registerDimension( storageCellDimID, AppEng.instance().getStorageDimensionType() );
}
this.config.save();
@@ -111,7 +111,7 @@ final class DimensionData implements IWorldDimensionData, IOnWorldStartable, IOn
public void addStorageCell( final int newStorageCellID )
{
this.storageCellDimensionIDs.add( newStorageCellID );
DimensionManager.registerDimension( newStorageCellID, AppEng.instance().getRegistration().getStorageDimensionType() );
DimensionManager.registerDimension( newStorageCellID, AppEng.instance().getStorageDimensionType() );
NetworkHandler.instance().sendToAll( new PacketNewStorageDimension( newStorageCellID ) );
@@ -1,133 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, 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.coremod;
import java.util.Map;
import javax.annotation.Nullable;
import com.google.common.eventbus.EventBus;
import org.apache.logging.log4j.Level;
import net.minecraftforge.fml.common.DummyModContainer;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.LoadController;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.ModMetadata;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.MCVersion;
import appeng.core.AEConfig;
@MCVersion( "1.12" )
public final class AppEngCore extends DummyModContainer implements IFMLLoadingPlugin
{
private final ModMetadata metadata = new ModMetadata();
public AppEngCore()
{
FMLLog.log( "AE2-CORE", Level.INFO, "[AppEng] Core Init" );
this.metadata.autogenerated = false;
this.metadata.authorList.add( "AlgorithmX2" );
this.metadata.credits = "AlgorithmX2";
this.metadata.modId = this.getModId();
this.metadata.version = this.getVersion();
this.metadata.name = this.getName();
this.metadata.url = "http://ae2.ae-mod.info";
this.metadata.logoFile = "assets/appliedenergistics2/meta/logo.png";
this.metadata.description = "Embedded Coremod for Applied Energistics 2";
}
@EventHandler
public void load( final FMLInitializationEvent event )
{
}
@Override
public String[] getASMTransformerClass()
{
return new String[] { "appeng.coremod.transformer.ASMIntegration" };
}
@Override
public String getModContainerClass()
{
return "appeng.coremod.AppEngCore";
}
@Nullable
@Override
public String getSetupClass()
{
return null;
}
@Override
public void injectData( final Map<String, Object> data )
{
}
@Override
public String getAccessTransformerClass()
{
return null;
}
@Override
public ModMetadata getMetadata()
{
return this.metadata;
}
@Override
public String getModId()
{
return "appliedenergistics2-core";
}
@Override
public String getName()
{
return "Applied Energistics 2 Core";
}
@Override
public String getVersion()
{
return AEConfig.VERSION;
}
@Override
public boolean registerBus( final EventBus bus, final LoadController controller )
{
return true;
}
@Override
public String getDisplayVersion()
{
return this.getVersion();
}
}
@@ -1,100 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, 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.coremod;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiErrorScreen;
import net.minecraftforge.fml.client.CustomModLoadingErrorDisplayException;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly( Side.CLIENT )
public final class MissingCoreMod extends CustomModLoadingErrorDisplayException
{
private static final int SHADOW_WHITE = 0xeeeeee;
private static final int COLOR_WHITE = 0xffffff;
private static final long serialVersionUID = -966774766922821652L;
private static final int SCREEN_OFFSET = 15;
private boolean deobf = false;
@Override
public void initGui( final GuiErrorScreen errorScreen, final FontRenderer fontRenderer )
{
final Class<?> clz = errorScreen.getClass();
try
{
clz.getField( "mc" );
this.deobf = true;
}
catch( final Throwable ignored )
{
}
}
@Override
public void drawScreen( final GuiErrorScreen errorScreen, final FontRenderer fontRenderer, final int mouseRelX, final int mouseRelY, final float tickTime )
{
int offset = 10;
this.drawCenteredString( fontRenderer, "Sorry, couldn't load AE2 properly.", errorScreen.width / 2, offset, COLOR_WHITE );
offset += SCREEN_OFFSET;
this.drawCenteredString( fontRenderer, "Please make sure that AE2 is installed into your mods folder.", errorScreen.width / 2, offset, SHADOW_WHITE );
offset += 2 * SCREEN_OFFSET;
if( this.deobf )
{
offset += SCREEN_OFFSET;
this.drawCenteredString( fontRenderer, "In a developer environment add the following too your args,", errorScreen.width / 2, offset, COLOR_WHITE );
offset += SCREEN_OFFSET;
this.drawCenteredString( fontRenderer, "-Dfml.coreMods.load=appeng.coremod.AppEngCore", errorScreen.width / 2, offset, SHADOW_WHITE );
}
else
{
this.drawCenteredString( fontRenderer, "Your launcher may refer to this by different names,", errorScreen.width / 2, offset, COLOR_WHITE );
offset += SCREEN_OFFSET + 5;
this.drawCenteredString( fontRenderer, "MultiMC calls this tab \"Loader Mods\"", errorScreen.width / 2, offset, SHADOW_WHITE );
offset += SCREEN_OFFSET;
this.drawCenteredString( fontRenderer, "Magic Launcher calls this tab \"External Mods\"", errorScreen.width / 2, offset, SHADOW_WHITE );
offset += SCREEN_OFFSET;
this.drawCenteredString( fontRenderer, "Most other launchers refer to this tab as just \"Mods\"", errorScreen.width / 2, offset, SHADOW_WHITE );
offset += 2 * SCREEN_OFFSET;
this.drawCenteredString( fontRenderer, "Also make sure that the AE2 file is a .jar, and not a .zip", errorScreen.width / 2, offset, COLOR_WHITE );
}
}
private void drawCenteredString( final FontRenderer fontRenderer, final String string, final int x, final int y, final int colour )
{
final String reEncoded = string.replaceAll( "\\P{InBasic_Latin}", "" );
final int reEncodedWidth = fontRenderer.getStringWidth( reEncoded );
final int centeredX = x - reEncodedWidth / 2;
fontRenderer.drawStringWithShadow( string, centeredX, y, colour );
}
}
@@ -1,54 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, 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.coremod.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import appeng.integration.IntegrationType;
public @interface Integration
{
@Retention( RetentionPolicy.RUNTIME )
@Target( ElementType.TYPE )
@interface InterfaceList
{
Interface[] value();
}
@Retention( RetentionPolicy.RUNTIME )
@Target( ElementType.TYPE )
@interface Interface
{
String iface();
IntegrationType iname();
}
@Retention( RetentionPolicy.RUNTIME )
@Target( ElementType.METHOD )
@interface Method
{
IntegrationType iname();
}
}
@@ -1,255 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, 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.coremod.transformer;
import java.util.Iterator;
import javax.annotation.Nullable;
import org.apache.logging.log4j.Level;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
import net.minecraft.launchwrapper.IClassTransformer;
import net.minecraftforge.fml.common.FMLLog;
import appeng.coremod.annotations.Integration;
import appeng.helpers.Reflected;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
@Reflected
public final class ASMIntegration implements IClassTransformer
{
@Reflected
public ASMIntegration()
{
/**
* Side, Display Name, ModID ClassPostFix
*/
for( final IntegrationType type : IntegrationType.values() )
{
IntegrationRegistry.INSTANCE.add( type );
}
// integrationModules.add( IntegrationSide.BOTH, "Thermal Expansion", "ThermalExpansion", IntegrationType.TE );
// integrationModules.add( IntegrationSide.BOTH, "Mystcraft", "Mystcraft", IntegrationType.Mystcraft );
// integrationModules.add( IntegrationSide.BOTH, "Greg Tech", "gregtech_addon", IntegrationType.GT );
// integrationModules.add( IntegrationSide.BOTH, "Universal Electricity", null, IntegrationType.UE );
// integrationModules.add( IntegrationSide.BOTH, "Logistics Pipes", "LogisticsPipes|Main", IntegrationType.LP );
// integrationModules.add( IntegrationSide.BOTH, "Better Storage", IntegrationType.betterstorage );
// integrationModules.add( IntegrationSide.BOTH, "Forestry", "Forestry", IntegrationType.Forestry );
// integrationModules.add( IntegrationSide.BOTH, "Mekanism", "Mekanism", IntegrationType.Mekanism );
}
@Nullable
@Override
public byte[] transform( final String name, final String transformedName, final byte[] basicClass )
{
if( basicClass == null || transformedName.startsWith( "appeng.coremod" ) )
{
return basicClass;
}
if( transformedName.startsWith( "appeng." ) )
{
final ClassNode classNode = new ClassNode();
final ClassReader classReader = new ClassReader( basicClass );
classReader.accept( classNode, 0 );
try
{
final boolean reWrite = this.removeOptionals( classNode );
if( reWrite )
{
final ClassWriter writer = new ClassWriter( ClassWriter.COMPUTE_MAXS );
classNode.accept( writer );
return writer.toByteArray();
}
}
catch( final Throwable t )
{
t.printStackTrace();
}
}
return basicClass;
}
private boolean removeOptionals( final ClassNode classNode )
{
boolean changed = false;
if( classNode.visibleAnnotations != null )
{
for( final AnnotationNode an : classNode.visibleAnnotations )
{
if( this.hasAnnotation( an, Integration.Interface.class ) )
{
if( this.stripInterface( classNode, Integration.Interface.class, an ) )
{
changed = true;
}
}
else if( this.hasAnnotation( an, Integration.InterfaceList.class ) )
{
for( final Object o : ( (Iterable) an.values.get( 1 ) ) )
{
if( this.stripInterface( classNode, Integration.InterfaceList.class, (AnnotationNode) o ) )
{
changed = true;
}
}
}
}
}
final Iterator<MethodNode> i = classNode.methods.iterator();
while( i.hasNext() )
{
final MethodNode mn = i.next();
if( mn.visibleAnnotations != null )
{
for( final AnnotationNode an : mn.visibleAnnotations )
{
if( this.hasAnnotation( an, Integration.Method.class ) )
{
if( this.stripMethod( classNode, mn, i, Integration.Method.class, an ) )
{
changed = true;
}
}
}
}
}
if( changed )
{
this.log( "Updated " + classNode.name );
}
return changed;
}
private boolean hasAnnotation( final AnnotationNode ann, final Class<?> annotation )
{
return ann.desc.equals( Type.getDescriptor( annotation ) );
}
private boolean stripInterface( final ClassNode classNode, final Class<?> class1, final AnnotationNode an )
{
if( an.values.size() != 4 )
{
throw new IllegalArgumentException( "Unable to handle Interface annotation on " + classNode.name );
}
String iFace = null;
if( an.values.get( 0 ).equals( "iface" ) )
{
iFace = (String) an.values.get( 1 );
}
else if( an.values.get( 2 ).equals( "iface" ) )
{
iFace = (String) an.values.get( 3 );
}
String iName = null;
if( an.values.get( 0 ).equals( "iname" ) )
{
iName = ( (String[]) an.values.get( 1 ) )[1];
}
else if( an.values.get( 2 ).equals( "iname" ) )
{
iName = ( (String[]) an.values.get( 3 ) )[1];
}
if( iName != null && iFace != null )
{
final IntegrationType type = IntegrationType.valueOf( iName );
if( !IntegrationRegistry.INSTANCE.isEnabled( type ) )
{
this.log( "Removing Interface " + iFace + " from " + classNode.name + " because " + iName + " integration is disabled." );
classNode.interfaces.remove( iFace.replace( '.', '/' ) );
return true;
}
else
{
this.log( "Allowing Interface " + iFace + " from " + classNode.name + " because " + iName + " integration is enabled." );
}
}
else
{
throw new IllegalStateException( "Unable to handle Method annotation on " + classNode.name );
}
return false;
}
private boolean stripMethod( final ClassNode classNode, final MethodNode mn, final Iterator<MethodNode> i, final Class class1, final AnnotationNode an )
{
if( an.values.size() != 2 )
{
throw new IllegalArgumentException( "Unable to handle Method annotation on " + classNode.name );
}
String iName = null;
if( an.values.get( 0 ).equals( "iname" ) )
{
iName = ( (String[]) an.values.get( 1 ) )[1];
}
if( iName != null )
{
final IntegrationType type = IntegrationType.valueOf( iName );
if( !IntegrationRegistry.INSTANCE.isEnabled( type ) )
{
this.log( "Removing Method " + mn.name + " from " + classNode.name + " because " + iName + " integration is disabled." );
i.remove();
return true;
}
else
{
this.log( "Allowing Method " + mn.name + " from " + classNode.name + " because " + iName + " integration is enabled." );
}
}
else
{
throw new IllegalStateException( "Unable to handle Method annotation on " + classNode.name );
}
return false;
}
private void log( final String string )
{
FMLLog.log( "AE2-CORE", Level.INFO, string );
}
}
+64 -109
View File
@@ -22,22 +22,28 @@ package appeng.debug;
import java.util.LinkedList;
import java.util.Queue;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import appeng.tile.AEBaseTile;
public class TileItemGen extends AEBaseTile implements IInventory
public class TileItemGen extends AEBaseTile
{
private static final Queue<ItemStack> POSSIBLE_ITEMS = new LinkedList<>();
private final IItemHandler handler = new QueuedItemHandler();
public TileItemGen()
{
if( POSSIBLE_ITEMS.isEmpty() )
@@ -45,7 +51,7 @@ public class TileItemGen extends AEBaseTile implements IInventory
for( final Object obj : Item.REGISTRY )
{
final Item mi = (Item) obj;
if( mi != null )
if( mi != null && mi != Items.AIR )
{
if( mi.isDamageable() )
{
@@ -66,126 +72,75 @@ public class TileItemGen extends AEBaseTile implements IInventory
}
@Override
public int getSizeInventory()
public boolean hasCapability( Capability<?> capability, @Nullable EnumFacing facing )
{
return 1;
}
@Override
public ItemStack getStackInSlot( final int i )
{
return this.getRandomItem();
}
private ItemStack getRandomItem()
{
// Safeguard for crash
ItemStack testStack = POSSIBLE_ITEMS.peek();
if( testStack.isEmpty() )
if( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY == capability )
{
testStack = new ItemStack( Blocks.COBBLESTONE, 1 );
return true;
}
return testStack;
return super.hasCapability( capability, facing );
}
@Override
public ItemStack decrStackSize( final int i, final int j )
@Nullable
public <T> T getCapability( Capability<T> capability, @Nullable EnumFacing facing )
{
final ItemStack a = POSSIBLE_ITEMS.poll();
final ItemStack out = a.copy();
POSSIBLE_ITEMS.add( a );
return out;
if( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY == capability )
{
return (T) this.handler;
}
return super.getCapability( capability, facing );
}
@Override
public ItemStack removeStackFromSlot( final int i )
{
return ItemStack.EMPTY;
}
@Override
public void setInventorySlotContents( final int i, final ItemStack itemstack )
{
final ItemStack a = POSSIBLE_ITEMS.poll();
POSSIBLE_ITEMS.add( a );
}
@Override
public String getName()
{
return null;
}
@Override
public boolean hasCustomName()
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 1;
}
@Override
public boolean isUsableByPlayer( final EntityPlayer entityplayer )
{
return false;
}
@Override
public void openInventory( final EntityPlayer player )
class QueuedItemHandler implements IItemHandler
{
}
@Override
@Nonnull
public ItemStack insertItem( int slot, @Nonnull ItemStack stack, boolean simulate )
{
return stack;
}
@Override
public void closeInventory( final EntityPlayer player )
{
@Override
@Nonnull
public ItemStack getStackInSlot( int slot )
{
return POSSIBLE_ITEMS.peek() != null ? POSSIBLE_ITEMS.peek().copy() : ItemStack.EMPTY;
}
}
@Override
public int getSlots()
{
return 1;
}
@Override
public boolean isItemValidForSlot( final int i, final ItemStack itemstack )
{
return false;
}
@Override
public int getSlotLimit( int slot )
{
return 1;
}
@Override
public ITextComponent getDisplayName()
{
return null;
}
@Override
@Nonnull
public ItemStack extractItem( int slot, int amount, boolean simulate )
{
final ItemStack is = POSSIBLE_ITEMS.peek();
@Override
public int getField( final int id )
{
return 0;
}
if( is == null )
{
return ItemStack.EMPTY;
}
@Override
public void setField( final int id, final int value )
{
return simulate ? is.copy() : this.getNextItem();
}
}
private ItemStack getNextItem()
{
final ItemStack is = POSSIBLE_ITEMS.poll();
@Override
public int getFieldCount()
{
return 0;
}
@Override
public void clear()
{
}
@Override
public boolean isEmpty()
{
// TODO Auto-generated method stub
return false;
}
POSSIBLE_ITEMS.add( is );
return is.copy();
}
};
}
@@ -40,6 +40,7 @@ public abstract class BlockSlabCommon extends BlockSlab
this.setDefaultState( iblockstate.withProperty( VARIANT, Variant.DEFAULT ) );
this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS );
this.useNeighborBrightness = true;
}
/**
@@ -1264,7 +1264,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
{
if( capabilityClass == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY )
{
return (T) storage;
return (T) this.storage;
}
else if( capabilityClass == Capabilities.STORAGE_MONITORABLE_ACCESSOR )
{
@@ -0,0 +1,157 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2017, tyra314, 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.helpers;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.text.TextFormatting;
import appeng.util.Platform;
public class InvalidPatternHelper
{
private final List<PatternIngredient> outputs = new ArrayList<>();
private final List<PatternIngredient> inputs = new ArrayList<>();
private final boolean isCrafting;
private final boolean canSubstitute;
public InvalidPatternHelper( final ItemStack is )
{
final NBTTagCompound encodedValue = is.getTagCompound();
if( encodedValue == null )
{
throw new IllegalArgumentException( "No pattern here!" );
}
final NBTTagList inTag = encodedValue.getTagList( "in", 10 );
final NBTTagList outTag = encodedValue.getTagList( "out", 10 );
this.isCrafting = encodedValue.getBoolean( "crafting" );
this.canSubstitute = this.isCrafting && encodedValue.getBoolean( "substitute" );
for( int i = 0; i < outTag.tagCount(); i++ )
{
this.outputs.add( new PatternIngredient( outTag.getCompoundTagAt( i ) ) );
}
for( int i = 0; i < inTag.tagCount(); i++ )
{
NBTTagCompound in = inTag.getCompoundTagAt( i );
// skip empty slots in the crafting grid
if( in.hasNoTags() )
{
continue;
}
this.inputs.add( new PatternIngredient( in ) );
}
}
public List<PatternIngredient> getOutputs()
{
return this.outputs;
}
public List<PatternIngredient> getInputs()
{
return this.inputs;
}
public boolean isCraftable()
{
return this.isCrafting;
}
public boolean canSubstitute()
{
return this.canSubstitute;
}
public class PatternIngredient
{
private String id;
private int count;
private int damage;
private ItemStack stack;
public PatternIngredient( NBTTagCompound tag )
{
this.stack = new ItemStack( tag );
if( this.stack.isEmpty() )
{
this.id = tag.getString( "id" );
this.count = tag.getByte( "Count" );
this.damage = Math.max( 0, tag.getShort( "Damage" ) );
}
}
public boolean isValid()
{
return !this.stack.isEmpty();
}
public String getName()
{
return this.isValid() ? Platform.getItemDisplayName( this.stack ) : this.id + '@' + String.valueOf( this.getDamage() );
}
public int getDamage()
{
return this.isValid() ? this.stack.getItemDamage() : this.damage;
}
public int getCount()
{
return this.isValid() ? this.stack.getCount() : this.count;
}
public ItemStack getItem()
{
if( !this.isValid() )
{
throw new IllegalArgumentException( "There is no valid ItemStack for this PatternIngredient" );
}
return this.stack;
}
public String getFormattedToolTip()
{
String result = String.valueOf( this.getCount() ) + ' ' + this.getName();
if( !this.isValid() )
{
result = TextFormatting.RED + ( ' ' + result );
}
return result;
}
}
}
@@ -85,7 +85,13 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
for( int x = 0; x < inTag.tagCount(); x++ )
{
final ItemStack gs = new ItemStack( inTag.getCompoundTagAt( x ) );
NBTTagCompound ingredient = inTag.getCompoundTagAt( x );
final ItemStack gs = new ItemStack( ingredient );
if( !ingredient.hasNoTags() && gs.isEmpty() )
{
throw new IllegalArgumentException( "No pattern here!" );
}
this.crafting.setInventorySlotContents( x, gs );
@@ -119,7 +125,13 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
for( int x = 0; x < outTag.tagCount(); x++ )
{
final ItemStack gs = new ItemStack( outTag.getCompoundTagAt( x ) );
NBTTagCompound resultItemTag = outTag.getCompoundTagAt( x );
final ItemStack gs = new ItemStack( resultItemTag );
if( !resultItemTag.hasNoTags() && gs.isEmpty() )
{
throw new IllegalArgumentException( "No pattern here!" );
}
if( !gs.isEmpty() )
{
@@ -21,7 +21,6 @@ package appeng.integration;
import appeng.integration.modules.ic2.IC2Module;
import appeng.integration.modules.jei.JEIModule;
import appeng.integration.modules.rf.RFModule;
import appeng.integration.modules.theoneprobe.TheOneProbeModule;
import appeng.integration.modules.waila.WailaModule;
@@ -39,24 +38,6 @@ public enum IntegrationType
RC( IntegrationSide.BOTH, "Railcraft", "railcraft" ),
RF( IntegrationSide.BOTH, "RedstoneFlux Power - Tiles", "redstoneflux" )
{
@Override
public IIntegrationModule createInstance()
{
return new RFModule();
}
},
RFItem( IntegrationSide.BOTH, "RedstoneFlux Power - Items", "redstoneflux" )
{
@Override
public IIntegrationModule createInstance()
{
return new RFModule();
}
},
MFR( IntegrationSide.BOTH, "Mine Factory Reloaded", "minefactoryreloaded" ),
Waila( IntegrationSide.BOTH, "Waila", "waila" )
@@ -24,7 +24,6 @@ import appeng.integration.abstraction.IInvTweaks;
import appeng.integration.abstraction.IJEI;
import appeng.integration.abstraction.IMekanism;
import appeng.integration.abstraction.IRC;
import appeng.integration.abstraction.IRF;
/**
@@ -43,8 +42,6 @@ public final class Integrations
static IInvTweaks invTweaks = new IInvTweaks.Stub();
static IRF redstoneflux = new IRF.Stub();
private Integrations()
{
}
@@ -104,10 +101,4 @@ public final class Integrations
return invTweaks;
}
static IRF setRedstoneFlux( IRF redstoneflux )
{
Integrations.redstoneflux = redstoneflux;
return redstoneflux;
}
}
@@ -22,12 +22,15 @@ package appeng.integration.modules.ic2;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import ic2.api.item.ElectricItem;
import appeng.api.AEApi;
import appeng.api.config.TunnelType;
import appeng.api.features.IP2PTunnelRegistry;
import appeng.integration.IntegrationHelper;
import appeng.integration.abstraction.IC2PowerSink;
import appeng.integration.abstraction.IIC2;
import appeng.integration.modules.ic2.energy.PoweredItemManager;
import appeng.tile.powersink.IExternalPowerSink;
@@ -39,7 +42,11 @@ public class IC2Module implements IIC2
public IC2Module()
{
IntegrationHelper.testClassExistence( this, ic2.api.energy.tile.IEnergyTile.class );
IntegrationHelper.testClassExistence( this, ic2.api.energy.tile.IEnergyAcceptor.class );
IntegrationHelper.testClassExistence( this, ic2.api.energy.tile.IEnergyEmitter.class );
IntegrationHelper.testClassExistence( this, ic2.api.energy.prefab.BasicSinkSource.class );
IntegrationHelper.testClassExistence( this, ic2.api.item.IC2Items.class );
IntegrationHelper.testClassExistence( this, ic2.api.item.IBackupElectricItemManager.class );
IntegrationHelper.testClassExistence( this, ic2.api.recipe.Recipes.class );
IntegrationHelper.testClassExistence( this, ic2.api.recipe.IRecipeInput.class );
}
@@ -53,6 +60,8 @@ public class IC2Module implements IIC2
{
reg.addNewAttunement( this.getCable( string ), TunnelType.IC2_POWER );
}
ElectricItem.registerBackupManager( new PoweredItemManager() );
}
private ItemStack getItem( final String name, String variant )
@@ -0,0 +1,126 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, 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.ic2.energy;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import ic2.api.item.IBackupElectricItemManager;
import appeng.api.config.Actionable;
import appeng.api.config.PowerUnits;
import appeng.api.implementations.items.IAEItemPowerStorage;
public class PoweredItemManager implements IBackupElectricItemManager
{
@Override
public double charge( ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate )
{
final double limit = this.getTransferLimit( stack );
final IAEItemPowerStorage poweredItem = (IAEItemPowerStorage) stack.getItem();
final double convertedPower = PowerUnits.EU.convertTo( PowerUnits.AE, amount );
double toAdd = convertedPower;
if( !ignoreTransferLimit && amount > limit )
{
toAdd = limit;
}
final double overflow = poweredItem.injectAEPower( stack, toAdd, simulate ? Actionable.SIMULATE : Actionable.MODULATE );
final double addedAmount = toAdd - (int) overflow;
return PowerUnits.AE.convertTo( PowerUnits.EU, addedAmount );
}
@Override
public double discharge( ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate )
{
return 0;
}
@Override
public double getCharge( ItemStack stack )
{
final IAEItemPowerStorage poweredItem = (IAEItemPowerStorage) stack.getItem();
return (int) PowerUnits.AE.convertTo( PowerUnits.EU, poweredItem.getAECurrentPower( stack ) );
}
@Override
public double getMaxCharge( ItemStack stack )
{
final IAEItemPowerStorage poweredItem = (IAEItemPowerStorage) stack.getItem();
return PowerUnits.AE.convertTo( PowerUnits.EU, poweredItem.getAEMaxPower( stack ) );
}
@Override
public boolean canUse( ItemStack stack, double amount )
{
return this.getCharge( stack ) > amount;
}
@Override
public boolean use( ItemStack stack, double amount, EntityLivingBase entity )
{
final IAEItemPowerStorage poweredItem = (IAEItemPowerStorage) stack.getItem();
if( this.canUse( stack, amount ) )
{
final double toUse = PowerUnits.EU.convertTo( PowerUnits.AE, amount );
poweredItem.extractAEPower( stack, toUse, Actionable.MODULATE );
return true;
}
return false;
}
@Override
public void chargeFromArmor( ItemStack stack, EntityLivingBase entity )
{
// TODO Auto-generated method stub
}
@Override
public String getToolTip( ItemStack stack )
{
return null;
}
@Override
public int getTier( ItemStack stack )
{
return 1;
}
@Override
public boolean handles( ItemStack stack )
{
return !stack.isEmpty() && ( stack.getItem() instanceof IAEItemPowerStorage );
}
private double getTransferLimit( ItemStack itemStack )
{
return Math.max( 32, this.getMaxCharge( itemStack ) / 200 );
}
}
@@ -22,6 +22,7 @@ package appeng.integration.modules.jei;
import java.util.ArrayList;
import java.util.List;
import mezz.jei.api.recipe.IRecipeCategory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
@@ -34,7 +35,6 @@ import mezz.jei.api.gui.IDrawableStatic;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeCategory;
import appeng.api.AEApi;
import appeng.api.config.CondenserOutput;
@@ -44,7 +44,7 @@ import appeng.core.AppEng;
import appeng.tile.misc.TileCondenser;
class CondenserCategory extends BlankRecipeCategory<CondenserOutputWrapper>
class CondenserCategory implements IRecipeCategory<CondenserOutputWrapper>
{
public static final String UID = "appliedenergistics2.condenser";
@@ -19,19 +19,19 @@
package appeng.integration.modules.jei;
import mezz.jei.api.recipe.IRecipeWrapperFactory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import appeng.api.config.CondenserOutput;
import appeng.core.AppEng;
class CondenserOutputHandler implements IRecipeHandler<CondenserOutput>
class CondenserOutputHandler implements IRecipeWrapperFactory<CondenserOutput>
{
private final ItemStack matterBall;
@@ -49,18 +49,6 @@ class CondenserOutputHandler implements IRecipeHandler<CondenserOutput>
this.iconButtonSingularity = guiHelper.createDrawable( statesLocation, 32, 112, 14, 14, 28, 0, 78, 0 );
}
@Override
public Class<CondenserOutput> getRecipeClass()
{
return CondenserOutput.class;
}
@Override
public String getRecipeCategoryUid( CondenserOutput recipe )
{
return CondenserCategory.UID;
}
@Override
public IRecipeWrapper getRecipeWrapper( CondenserOutput recipe )
{
@@ -74,18 +62,4 @@ class CondenserOutputHandler implements IRecipeHandler<CondenserOutput>
return null;
}
}
@Override
public boolean isRecipeValid( CondenserOutput recipe )
{
switch( recipe )
{
case MATTER_BALLS:
return this.matterBall != null;
case SINGULARITY:
return this.singularity != null;
default:
return false;
}
}
}
@@ -26,6 +26,7 @@ import javax.annotation.Nullable;
import com.google.common.base.Splitter;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
@@ -33,12 +34,11 @@ import net.minecraftforge.fml.client.config.HoverChecker;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeWrapper;
import appeng.api.config.CondenserOutput;
class CondenserOutputWrapper extends BlankRecipeWrapper
class CondenserOutputWrapper implements IRecipeWrapper
{
private final ItemStack outputItem;
@@ -25,14 +25,13 @@ import java.util.List;
import net.minecraft.item.ItemStack;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeWrapper;
import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper;
/**
* Acts as a fake facade recipe wrapper, created by {@link FacadeRegistryPlugin}.
*/
class FacadeRecipeWrapper extends BlankRecipeWrapper implements IShapedCraftingRecipeWrapper
class FacadeRecipeWrapper implements IShapedCraftingRecipeWrapper
{
private final ItemStack textureItem;
@@ -19,6 +19,9 @@
package appeng.integration.modules.jei;
import mezz.jei.api.IJeiHelpers;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
@@ -27,12 +30,11 @@ import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeCategory;
import appeng.core.AppEng;
class GrinderRecipeCategory extends BlankRecipeCategory<GrinderRecipeWrapper>
class GrinderRecipeCategory implements IRecipeCategory<GrinderRecipeWrapper>, IRecipeCategoryRegistration
{
public static final String UID = "appliedenergistics2.grinder";
@@ -85,4 +87,14 @@ class GrinderRecipeCategory extends BlankRecipeCategory<GrinderRecipeWrapper>
itemStacks.set( ingredients );
}
@Override public void addRecipeCategories( IRecipeCategory... recipeCategories )
{
}
@Override public IJeiHelpers getJeiHelpers()
{
return null;
}
}
@@ -19,36 +19,16 @@
package appeng.integration.modules.jei;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import appeng.api.features.IGrinderRecipe;
import mezz.jei.api.recipe.IRecipeWrapperFactory;
class GrinderRecipeHandler implements IRecipeHandler<IGrinderRecipe>
class GrinderRecipeHandler implements IRecipeWrapperFactory<IGrinderRecipe>
{
@Override
public Class<IGrinderRecipe> getRecipeClass()
{
return IGrinderRecipe.class;
}
@Override
public String getRecipeCategoryUid( IGrinderRecipe recipe )
{
return GrinderRecipeCategory.UID;
}
@Override
public IRecipeWrapper getRecipeWrapper( IGrinderRecipe recipe )
{
return new GrinderRecipeWrapper( recipe );
}
@Override
public boolean isRecipeValid( IGrinderRecipe recipe )
{
return true;
}
}
@@ -23,18 +23,18 @@ import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.item.ItemStack;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeWrapper;
import appeng.api.features.IGrinderRecipe;
class GrinderRecipeWrapper extends BlankRecipeWrapper
class GrinderRecipeWrapper implements IRecipeWrapper
{
private final IGrinderRecipe recipe;
@@ -19,6 +19,8 @@
package appeng.integration.modules.jei;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
@@ -30,12 +32,11 @@ import mezz.jei.api.gui.IDrawableStatic;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeCategory;
import appeng.core.AppEng;
class InscriberRecipeCategory extends BlankRecipeCategory<InscriberRecipeWrapper>
class InscriberRecipeCategory implements IRecipeCategory<InscriberRecipeWrapper>
{
private static final int SLOT_INPUT_TOP = 0;
@@ -19,37 +19,18 @@
package appeng.integration.modules.jei;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import appeng.api.features.IInscriberRecipe;
import mezz.jei.api.recipe.IRecipeWrapperFactory;
class InscriberRecipeHandler implements IRecipeHandler<IInscriberRecipe>
class InscriberRecipeHandler implements IRecipeWrapperFactory<IInscriberRecipe>
{
@Override
public Class<IInscriberRecipe> getRecipeClass()
{
return IInscriberRecipe.class;
}
@Override
public String getRecipeCategoryUid( IInscriberRecipe recipe )
{
return InscriberRecipeCategory.UID;
}
@Override
public IRecipeWrapper getRecipeWrapper( IInscriberRecipe recipe )
{
return new InscriberRecipeWrapper( recipe );
}
@Override
public boolean isRecipeValid( IInscriberRecipe recipe )
{
return true;
}
}
@@ -23,15 +23,15 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeWrapper;
import appeng.api.features.IInscriberRecipe;
class InscriberRecipeWrapper extends BlankRecipeWrapper
class InscriberRecipeWrapper implements IRecipeWrapper
{
private final IInscriberRecipe recipe;
@@ -23,15 +23,19 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import appeng.api.features.IGrinderRecipe;
import appeng.recipes.game.ShapedRecipe;
import appeng.recipes.game.ShapelessRecipe;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import mezz.jei.api.BlankModPlugin;
import mezz.jei.api.IJeiRuntime;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import appeng.api.AEApi;
@@ -45,17 +49,27 @@ import appeng.container.implementations.ContainerPatternTerm;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.integration.Integrations;
import appeng.items.parts.ItemFacade;
@mezz.jei.api.JEIPlugin
public class JEIPlugin extends BlankModPlugin
public class JEIPlugin implements IModPlugin
{
@Override
public void registerCategories( IRecipeCategoryRegistration registry )
{
registry.addRecipeCategories( new GrinderRecipeCategory( registry.getJeiHelpers().getGuiHelper() ) );
registry.addRecipeCategories( new CondenserCategory( registry.getJeiHelpers().getGuiHelper() ) );
registry.addRecipeCategories( new InscriberRecipeCategory( registry.getJeiHelpers().getGuiHelper() ) );
}
@Override
public void register( IModRegistry registry )
{
registry.addRecipeHandlers( new ShapedRecipeHandler(), new ShapelessRecipeHandler() );
registry.handleRecipes( ShapedRecipe.class, new ShapedRecipeHandler(), VanillaRecipeCategoryUid.CRAFTING );
registry.handleRecipes( ShapelessRecipe.class, new ShapelessRecipeHandler(), VanillaRecipeCategoryUid.CRAFTING );
IDefinitions definitions = AEApi.instance().definitions();
@@ -119,7 +133,7 @@ public class JEIPlugin extends BlankModPlugin
private void addDescription( IModRegistry registry, IItemDefinition itemDefinition, String message )
{
itemDefinition.maybeStack( 1 ).ifPresent( itemStack -> registry.addDescription( itemStack, message ) );
itemDefinition.maybeStack( 1 ).ifPresent( itemStack -> registry.addIngredientInfo( itemStack, ItemStack.class, message ) );
}
private void registerGrinderRecipes( IDefinitions definitions, IModRegistry registry )
@@ -132,10 +146,9 @@ public class JEIPlugin extends BlankModPlugin
return;
}
registry.addRecipes( Lists.newArrayList( AEApi.instance().registries().grinder().getRecipes() ) );
registry.addRecipeHandlers( new GrinderRecipeHandler() );
registry.addRecipeCategories( new GrinderRecipeCategory( registry.getJeiHelpers().getGuiHelper() ) );
registry.addRecipeCategoryCraftingItem( grindstone, GrinderRecipeCategory.UID );
registry.handleRecipes( IGrinderRecipe.class, new GrinderRecipeHandler(), GrinderRecipeCategory.UID );
registry.addRecipes( Lists.newArrayList( AEApi.instance().registries().grinder().getRecipes() ), GrinderRecipeCategory.UID );
registry.addRecipeCatalyst( grindstone, GrinderRecipeCategory.UID );
}
private void registerCondenserRecipes( IDefinitions definitions, IModRegistry registry )
@@ -150,38 +163,34 @@ public class JEIPlugin extends BlankModPlugin
ItemStack matterBall = definitions.materials().matterBall().maybeStack( 1 ).orElse( ItemStack.EMPTY );
if( !matterBall.isEmpty() )
{
registry.addRecipes( ImmutableList.of( CondenserOutput.MATTER_BALLS ) );
registry.addRecipes( ImmutableList.of( CondenserOutput.MATTER_BALLS ), CondenserCategory.UID );
}
ItemStack singularity = definitions.materials().singularity().maybeStack( 1 ).orElse( ItemStack.EMPTY );
if( !singularity.isEmpty() )
{
registry.addRecipes( ImmutableList.of( CondenserOutput.SINGULARITY ) );
registry.addRecipes( ImmutableList.of( CondenserOutput.SINGULARITY ), CondenserCategory.UID );
}
if( !matterBall.isEmpty() || !singularity.isEmpty() )
{
registry.addRecipeCategories( new CondenserCategory( registry.getJeiHelpers().getGuiHelper() ) );
registry.addRecipeCategoryCraftingItem( condenser, CondenserCategory.UID );
registry.addRecipeHandlers( new CondenserOutputHandler( registry.getJeiHelpers().getGuiHelper(), matterBall, singularity ) );
registry.addRecipeCatalyst( condenser, CondenserCategory.UID );
registry.handleRecipes( CondenserOutput.class, new CondenserOutputHandler( registry.getJeiHelpers().getGuiHelper(), matterBall, singularity) , CondenserCategory.UID );
}
}
private void registerInscriberRecipes( IDefinitions definitions, IModRegistry registry )
{
registry.addRecipeHandlers( new InscriberRecipeHandler() );
registry.addRecipeCategories( new InscriberRecipeCategory( registry.getJeiHelpers().getGuiHelper() ) );
registry.handleRecipes( IInscriberRecipe.class, new InscriberRecipeHandler(), InscriberRecipeCategory.UID );
// Register the inscriber as the crafting item for the inscription category
definitions.blocks().inscriber().maybeStack( 1 ).ifPresent( inscriber ->
{
registry.addRecipeCategoryCraftingItem( inscriber, InscriberRecipeCategory.UID );
registry.addRecipeCatalyst( inscriber, InscriberRecipeCategory.UID );
} );
List<IInscriberRecipe> inscriberRecipes = new ArrayList<>( AEApi.instance().registries().inscriber().getRecipes() );
registry.addRecipes( inscriberRecipes );
registry.addRecipes( inscriberRecipes, InscriberRecipeCategory.UID );
}
// Handle the generic crafting recipe for patterns in JEI
@@ -198,7 +207,7 @@ public class JEIPlugin extends BlankModPlugin
@Override
public void onRuntimeAvailable( IJeiRuntime jeiRuntime )
{
// JEIModule jeiModule = (JEIModule) Integrations.jei();
// jeiModule.setJei( new JeiRuntimeAdapter( jeiRuntime ) );
JEIModule jeiModule = (JEIModule) Integrations.jei();
jeiModule.setJei( new JeiRuntimeAdapter( jeiRuntime ) );
}
}
@@ -45,12 +45,12 @@ class JeiRuntimeAdapter implements IJEI
@Override
public String getSearchText()
{
return Strings.nullToEmpty( this.runtime.getItemListOverlay().getFilterText() );
return Strings.nullToEmpty( this.runtime.getIngredientFilter().getFilterText() );
}
@Override
public void setSearchText( String searchText )
{
this.runtime.getItemListOverlay().setFilterText( Strings.nullToEmpty( searchText ) );
this.runtime.getIngredientFilter().setFilterText( Strings.nullToEmpty( searchText ) );
}
}
@@ -19,37 +19,17 @@
package appeng.integration.modules.jei;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import mezz.jei.api.recipe.IRecipeWrapperFactory;
import appeng.recipes.game.ShapedRecipe;
class ShapedRecipeHandler implements IRecipeHandler<ShapedRecipe>
class ShapedRecipeHandler implements IRecipeWrapperFactory<ShapedRecipe>
{
@Override
public Class<ShapedRecipe> getRecipeClass()
{
return ShapedRecipe.class;
}
@Override
public String getRecipeCategoryUid( ShapedRecipe recipe )
{
return VanillaRecipeCategoryUid.CRAFTING;
}
@Override
public IRecipeWrapper getRecipeWrapper( ShapedRecipe recipe )
{
return new ShapedRecipeWrapper( recipe );
}
@Override
public boolean isRecipeValid( ShapedRecipe recipe )
{
return recipe.isEnabled();
}
}
@@ -26,7 +26,6 @@ import java.util.List;
import net.minecraft.item.ItemStack;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeWrapper;
import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper;
import scala.actors.threadpool.Arrays;
@@ -38,7 +37,7 @@ import appeng.recipes.game.ShapedRecipe;
import appeng.util.Platform;
class ShapedRecipeWrapper extends BlankRecipeWrapper implements IShapedCraftingRecipeWrapper
class ShapedRecipeWrapper implements IShapedCraftingRecipeWrapper
{
private final ShapedRecipe recipe;
@@ -19,37 +19,17 @@
package appeng.integration.modules.jei;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import mezz.jei.api.recipe.IRecipeWrapperFactory;
import appeng.recipes.game.ShapelessRecipe;
class ShapelessRecipeHandler implements IRecipeHandler<ShapelessRecipe>
class ShapelessRecipeHandler implements IRecipeWrapperFactory<ShapelessRecipe>
{
@Override
public Class<ShapelessRecipe> getRecipeClass()
{
return ShapelessRecipe.class;
}
@Override
public String getRecipeCategoryUid( ShapelessRecipe recipe )
{
return VanillaRecipeCategoryUid.CRAFTING;
}
@Override
public IRecipeWrapper getRecipeWrapper( ShapelessRecipe recipe )
{
return new ShapelessRecipeWrapper( recipe );
}
@Override
public boolean isRecipeValid( ShapelessRecipe recipe )
{
return recipe.isEnabled();
}
}
@@ -24,11 +24,10 @@ import java.util.List;
import com.google.common.collect.Lists;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeWrapper;
import mezz.jei.api.recipe.wrapper.ICraftingRecipeWrapper;
import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RegistrationError;
@@ -36,7 +35,7 @@ import appeng.api.recipes.IIngredient;
import appeng.recipes.game.ShapelessRecipe;
class ShapelessRecipeWrapper extends BlankRecipeWrapper implements ICraftingRecipeWrapper
class ShapelessRecipeWrapper implements IRecipeWrapper
{
private final ShapelessRecipe recipe;
@@ -31,7 +31,7 @@ import mcjty.theoneprobe.api.ProbeMode;
import appeng.api.parts.IPart;
import appeng.integration.modules.theoneprobe.TheOneProbeText;
import appeng.parts.networking.PartCableSmart;
import appeng.parts.networking.PartDenseCable;
import appeng.parts.networking.PartDenseCableSmart;
public class ChannelInfoProvider implements IPartProbInfoProvider
@@ -40,10 +40,10 @@ public class ChannelInfoProvider implements IPartProbInfoProvider
@Override
public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data )
{
if( part instanceof PartDenseCable || part instanceof PartCableSmart )
if( part instanceof PartDenseCableSmart || part instanceof PartCableSmart )
{
final int usedChannels;
final int maxChannels = ( part instanceof PartDenseCable ) ? 32 : 8;
final int maxChannels = ( part instanceof PartDenseCableSmart ) ? 32 : 8;
if( part.getGridNode().isActive() )
{
@@ -35,7 +35,7 @@ import mcp.mobius.waila.api.IWailaDataAccessor;
import appeng.api.parts.IPart;
import appeng.core.localization.WailaText;
import appeng.parts.networking.PartCableSmart;
import appeng.parts.networking.PartDenseCable;
import appeng.parts.networking.PartDenseCableSmart;
/**
@@ -75,7 +75,7 @@ public final class ChannelWailaDataProvider extends BasePartWailaDataProvider
@Override
public List<String> getWailaBody( final IPart part, final List<String> currentToolTip, final IWailaDataAccessor accessor, final IWailaConfigHandler config )
{
if( part instanceof PartCableSmart || part instanceof PartDenseCable )
if( part instanceof PartCableSmart || part instanceof PartDenseCableSmart )
{
final NBTTagCompound tag = accessor.getNBTData();
@@ -83,7 +83,7 @@ public final class ChannelWailaDataProvider extends BasePartWailaDataProvider
if( usedChannels >= 0 )
{
final byte maxChannels = (byte) ( ( part instanceof PartDenseCable ) ? 32 : 8 );
final byte maxChannels = (byte) ( ( part instanceof PartDenseCableSmart ) ? 32 : 8 );
final String formattedToolTip = String.format( WailaText.Channels.getLocal(), usedChannels, maxChannels );
currentToolTip.add( formattedToolTip );
@@ -144,7 +144,7 @@ public final class ChannelWailaDataProvider extends BasePartWailaDataProvider
@Override
public NBTTagCompound getNBTData( EntityPlayerMP player, IPart part, TileEntity te, NBTTagCompound tag, World world, BlockPos pos )
{
if( part instanceof PartCableSmart || part instanceof PartDenseCable )
if( part instanceof PartCableSmart || part instanceof PartDenseCableSmart )
{
final NBTTagCompound tempTag = new NBTTagCompound();
@@ -54,7 +54,7 @@ public class NetworkToolViewer implements INetworkTool, IAEAppEngInventory
@Override
public void saveChanges()
{
inv.markDirty( -1 );
this.inv.markDirty( -1 );
}
@Override
@@ -92,7 +92,7 @@ public class NetworkToolViewer implements INetworkTool, IAEAppEngInventory
public IItemHandler getInternalInventory()
{
return inv;
return this.inv;
}
@Override
@@ -79,7 +79,7 @@ public class PortableCellViewer extends MEMonitorHandler<IAEItemStack> implement
return usePowerMultiplier.divide( Math.min( amt, this.ips.getAECurrentPower( this.target ) ) );
}
return usePowerMultiplier.divide( this.ips.extractAEPower( this.target, amt ) );
return usePowerMultiplier.divide( this.ips.extractAEPower( this.target, amt, Actionable.MODULATE ) );
}
@Override
@@ -43,6 +43,7 @@ import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.AppEng;
import appeng.core.localization.GuiText;
import appeng.helpers.InvalidPatternHelper;
import appeng.helpers.PatternHelper;
import appeng.items.AEBaseItem;
import appeng.util.Platform;
@@ -108,10 +109,49 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
if( details == null )
{
lines.add( TextFormatting.RED + GuiText.InvalidPattern.getLocal() );
if( !stack.hasTagCompound() )
{
return;
}
stack.setStackDisplayName( TextFormatting.RED + GuiText.InvalidPattern.getLocal() );
InvalidPatternHelper invalid = new InvalidPatternHelper( stack );
final String label = ( invalid.isCraftable() ? GuiText.Crafts.getLocal() : GuiText.Creates.getLocal() ) + ": ";
final String and = ' ' + GuiText.And.getLocal() + ' ';
final String with = GuiText.With.getLocal() + ": ";
boolean first = true;
for( final InvalidPatternHelper.PatternIngredient output : invalid.getOutputs() )
{
lines.add( ( first ? label : and ) + output.getFormattedToolTip() );
first = false;
}
first = true;
for( final InvalidPatternHelper.PatternIngredient input : invalid.getInputs() )
{
lines.add( ( first ? with : and ) + input.getFormattedToolTip() );
first = false;
}
if( invalid.isCraftable() )
{
final String substitutionLabel = GuiText.Substitute.getLocal() + " ";
final String canSubstitute = invalid.canSubstitute() ? GuiText.Yes.getLocal() : GuiText.No.getLocal();
lines.add( substitutionLabel + canSubstitute );
}
return;
}
if( stack.hasDisplayName() )
{
stack.removeSubCompound( "display" );
}
final boolean isCrafting = details.isCraftable();
final boolean substitute = details.canSubstitute();
+10 -1
View File
@@ -343,7 +343,16 @@ public final class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
@Override
public int compare( final Entry<Integer, PartTypeWithVariant> o1, final Entry<Integer, PartTypeWithVariant> o2 )
{
return o1.getValue().part.name().compareTo( o2.getValue().part.name() );
final String string1 = o1.getValue().part.name();
final String string2 = o2.getValue().part.name();
final int comparedString = string1.compareTo( string2 );
if( comparedString == 0 )
{
return Integer.compare( o1.getKey(), o2.getKey() );
}
return comparedString;
}
}
+22 -13
View File
@@ -57,14 +57,14 @@ import appeng.parts.misc.PartToggleBus;
import appeng.parts.networking.PartCableCovered;
import appeng.parts.networking.PartCableGlass;
import appeng.parts.networking.PartCableSmart;
import appeng.parts.networking.PartDenseCable;
import appeng.parts.networking.PartDenseCableCovered;
import appeng.parts.networking.PartDenseCableSmart;
import appeng.parts.networking.PartQuartzFiber;
import appeng.parts.p2p.PartP2PFEPower;
import appeng.parts.p2p.PartP2PFluids;
import appeng.parts.p2p.PartP2PIC2Power;
import appeng.parts.p2p.PartP2PItems;
import appeng.parts.p2p.PartP2PLight;
import appeng.parts.p2p.PartP2PRFPower;
import appeng.parts.p2p.PartP2PRedstone;
import appeng.parts.p2p.PartP2PTunnelME;
import appeng.parts.reporting.PartConversionMonitor;
@@ -138,7 +138,26 @@ public enum PartType
},
CABLE_DENSE_SMART( 60, "cable_dense_smart", EnumSet.of( AEFeature.CHANNELS, AEFeature.DENSE_CABLES ), EnumSet
.noneOf( IntegrationType.class ), PartDenseCable.class )
.noneOf( IntegrationType.class ), PartDenseCableSmart.class )
{
@Override
public boolean isCable()
{
return true;
}
@Override
@SideOnly( Side.CLIENT )
protected List<ModelResourceLocation> createItemModels( String baseName )
{
return Arrays.stream( AEColor.values() )
.map( color -> modelFromBaseName( baseName + "_" + color.name().toLowerCase() ) )
.collect( Collectors.toList() );
}
},
CABLE_DENSE_COVERED( 500, "cable_dense_covered", EnumSet.of( AEFeature.CHANNELS, AEFeature.DENSE_CABLES ), EnumSet
.noneOf( IntegrationType.class ), PartDenseCableCovered.class )
{
@Override
public boolean isCable()
@@ -250,16 +269,6 @@ public enum PartType
}
},
P2P_TUNNEL_RF( 466, "p2p_tunnel_rf", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_RF ), EnumSet
.of( IntegrationType.RF ), PartP2PRFPower.class, GuiText.RFTunnel )
{
@Override
String getUnlocalizedName()
{
return "p2p_tunnel";
}
},
P2P_TUNNEL_LIGHT( 467, "p2p_tunnel_light", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_LIGHT ), EnumSet
.noneOf( IntegrationType.class ), PartP2PLight.class, GuiText.LightTunnel )
{
@@ -146,11 +146,14 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
@Override
public EnumActionResult onItemUse( final EntityPlayer player, final World w, final BlockPos pos, final EnumHand hand, final EnumFacing side, final float hx, final float hy, final float hz )
{
if( player.isSneaking() && !w.isRemote )
if( player.isSneaking() )
{
final IMemoryCard mem = (IMemoryCard) player.getHeldItem( hand ).getItem();
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
player.getHeldItem( hand ).setTagCompound( null );
if( !w.isRemote )
{
final IMemoryCard mem = (IMemoryCard) player.getHeldItem( hand ).getItem();
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
player.getHeldItem( hand ).setTagCompound( null );
}
return EnumActionResult.SUCCESS;
}
else
@@ -24,6 +24,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.AxisAlignedBB;
import appeng.api.config.Actionable;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.core.sync.packets.PacketLightning;
@@ -44,7 +45,7 @@ public class ToolChargedStaff extends AEBasePoweredItem
{
if( this.getAECurrentPower( item ) > 300 )
{
this.extractAEPower( item, 300 );
this.extractAEPower( item, 300, Actionable.MODULATE );
if( Platform.isServer() )
{
for( int x = 0; x < 2; x++ )
@@ -151,7 +151,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
if( ( (IColorableTile) te ).recolourBlock( side, AEColor.TRANSPARENT, p ) )
{
inv.extractItems( AEItemStack.create( paintBall ), Actionable.MODULATE, new BaseActionSource() );
this.extractAEPower( is, powerPerUse );
this.extractAEPower( is, powerPerUse, Actionable.MODULATE );
return EnumActionResult.SUCCESS;
}
}
@@ -163,7 +163,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
if( this.getAECurrentPower( is ) > powerPerUse && testBlk instanceof BlockPaint && painted instanceof TilePaint )
{
inv.extractItems( AEItemStack.create( paintBall ), Actionable.MODULATE, new BaseActionSource() );
this.extractAEPower( is, powerPerUse );
this.extractAEPower( is, powerPerUse, Actionable.MODULATE );
( (TilePaint) painted ).cleanSide( side.getOpposite() );
return EnumActionResult.SUCCESS;
}
@@ -177,7 +177,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
if( color != AEColor.TRANSPARENT && this.recolourBlock( blk, side, w, pos, side, color, p ) )
{
inv.extractItems( AEItemStack.create( paintBall ), Actionable.MODULATE, new BaseActionSource() );
this.extractAEPower( is, powerPerUse );
this.extractAEPower( is, powerPerUse, Actionable.MODULATE );
return EnumActionResult.SUCCESS;
}
}
@@ -45,6 +45,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import appeng.api.config.Actionable;
import appeng.api.util.DimensionalCoord;
import appeng.block.misc.BlockTinyTNT;
import appeng.core.AEConfig;
@@ -204,7 +205,7 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
{
if( this.getAECurrentPower( item ) > 1600 )
{
this.extractAEPower( item, 1600 );
this.extractAEPower( item, 1600, Actionable.MODULATE );
target.setFire( 8 );
}
@@ -261,7 +262,7 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
{
if( this.canCool( state ) )
{
this.extractAEPower( item, 1600 );
this.extractAEPower( item, 1600, Actionable.MODULATE );
this.cool( state, w, pos );
return EnumActionResult.SUCCESS;
}
@@ -284,7 +285,7 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
if( this.canHeat( state ) )
{
this.extractAEPower( item, 1600 );
this.extractAEPower( item, 1600, Actionable.MODULATE );
this.heat( state, w, pos );
return EnumActionResult.SUCCESS;
}
@@ -320,7 +321,7 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
if( hasFurnaceable && canFurnaceable )
{
this.extractAEPower( item, 1600 );
this.extractAEPower( item, 1600, Actionable.MODULATE );
final InWorldToolOperationResult or = InWorldToolOperationResult.getBlockOperationResult( out.toArray( new ItemStack[out.size()] ) );
w.playSound( p, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.PLAYERS, 1.0F,
itemRand.nextFloat() * 0.4F + 0.8F );
@@ -353,7 +354,7 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
if( w.isAirBlock( offsetPos ) )
{
this.extractAEPower( item, 1600 );
this.extractAEPower( item, 1600, Actionable.MODULATE );
w.playSound( p, offsetPos.getX() + 0.5D, offsetPos.getY() + 0.5D, offsetPos.getZ() + 0.5D, SoundEvents.ITEM_FLINTANDSTEEL_USE,
SoundCategory.PLAYERS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F );
w.setBlockState( offsetPos, Blocks.FIRE.getDefaultState() );
@@ -132,7 +132,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell
shots = Math.min( shots, (int) aeAmmo.getStackSize() );
for( int sh = 0; sh < shots; sh++ )
{
this.extractAEPower( p.getHeldItem( hand ), 1600 );
this.extractAEPower( p.getHeldItem( hand ), 1600, Actionable.MODULATE );
if( Platform.isClient() )
{

Some files were not shown because too many files have changed in this diff Show More