Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8d5cc916e0 | |||
| 5abb8bf886 | |||
| 0bed78a144 | |||
| 30940e91ea | |||
| 0f9ac5fdda | |||
| 5e001d86cb | |||
| b13a338948 | |||
| 454404b0c1 |
@@ -235,7 +235,7 @@ class BlockDefinitionBuilder implements IBlockBuilder
|
||||
// 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.modelRegCallbacks.forEach( consumer -> this.factory.addModelReg( ( side, reg ) -> consumer.accept( block, item ) ) );
|
||||
this.postInitCallbacks.forEach( consumer -> this.factory.addPostInit( side -> consumer.accept( block, item ) ) );
|
||||
|
||||
if( this.tileEntityDefinition != null && block instanceof AEBaseTileBlock )
|
||||
|
||||
@@ -33,11 +33,11 @@ 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.IInitComponent;
|
||||
import appeng.bootstrap.components.IModelRegistrationComponent;
|
||||
import appeng.bootstrap.components.IPostInitComponent;
|
||||
import appeng.bootstrap.components.IPreInitComponent;
|
||||
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;
|
||||
@@ -128,22 +128,22 @@ public class FeatureFactory
|
||||
this.bootstrapComponents.add( component );
|
||||
}
|
||||
|
||||
void addPreInit( PreInitComponent component )
|
||||
void addPreInit( IPreInitComponent component )
|
||||
{
|
||||
this.bootstrapComponents.add( component );
|
||||
}
|
||||
|
||||
void addInit( InitComponent component )
|
||||
void addInit( IInitComponent component )
|
||||
{
|
||||
this.bootstrapComponents.add( component );
|
||||
}
|
||||
|
||||
void addModelReg( ModelRegComponent component )
|
||||
void addModelReg( IModelRegistrationComponent component )
|
||||
{
|
||||
this.bootstrapComponents.add( component );
|
||||
}
|
||||
|
||||
void addPostInit( PostInitComponent component )
|
||||
void addPostInit( IPostInitComponent component )
|
||||
{
|
||||
this.bootstrapComponents.add( component );
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public interface IBootstrapComponent
|
||||
{
|
||||
}
|
||||
|
||||
default void modelReg( Side side )
|
||||
default void modelRegistration( Side side, IModelRegistry registry )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.bootstrap;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
public interface IModelRegistry
|
||||
{
|
||||
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 );
|
||||
}
|
||||
@@ -165,7 +165,7 @@ class ItemDefinitionBuilder implements IItemBuilder
|
||||
// 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.modelRegCallbacks.forEach( consumer -> this.factory.addModelReg( ( side, reg ) -> consumer.accept( item ) ) );
|
||||
this.postInitCallbacks.forEach( consumer -> this.factory.addPostInit( side -> consumer.accept( item ) ) );
|
||||
|
||||
// Register custom dispenser behavior if requested
|
||||
|
||||
@@ -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<>();
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import appeng.bootstrap.IBootstrapComponent;
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface InitComponent extends IBootstrapComponent
|
||||
public interface IInitComponent extends IBootstrapComponent
|
||||
{
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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
|
||||
{
|
||||
|
||||
@Override
|
||||
void modelRegistration( Side side, IModelRegistry registry );
|
||||
|
||||
}
|
||||
+1
-1
@@ -25,7 +25,7 @@ import appeng.bootstrap.IBootstrapComponent;
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PostInitComponent extends IBootstrapComponent
|
||||
public interface IPostInitComponent extends IBootstrapComponent
|
||||
{
|
||||
|
||||
@Override
|
||||
+1
-1
@@ -25,7 +25,7 @@ import appeng.bootstrap.IBootstrapComponent;
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PreInitComponent extends IBootstrapComponent
|
||||
public interface IPreInitComponent extends IBootstrapComponent
|
||||
{
|
||||
|
||||
@Override
|
||||
@@ -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<>();
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -30,12 +30,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;
|
||||
@@ -66,6 +70,7 @@ 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.bootstrap.IModelRegistry;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.registries.P2PTunnelRegistry;
|
||||
@@ -374,12 +379,9 @@ public final class Registration
|
||||
@SubscribeEvent
|
||||
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();
|
||||
definitions.getRegistry().getBootstrapComponents().forEach( b -> b.modelRegistration( FMLCommonHandler.instance().getEffectiveSide(), registry ) );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -628,4 +630,34 @@ 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 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) 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() : 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();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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++ )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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( stack.isEmpty() )
|
||||
{
|
||||
this.id = tag.getString( "id" );
|
||||
this.count = tag.getByte( "Count" );
|
||||
this.damage = Math.max( 0, tag.getShort( "Damage" ) );
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
return !stack.isEmpty();
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return isValid() ? Platform.getItemDisplayName( stack ) : id + '@' + String.valueOf( getDamage() );
|
||||
}
|
||||
|
||||
public int getDamage()
|
||||
{
|
||||
return isValid() ? stack.getItemDamage() : damage;
|
||||
}
|
||||
|
||||
public int getCount()
|
||||
{
|
||||
return isValid() ? stack.getCount() : count;
|
||||
}
|
||||
|
||||
public ItemStack getItem()
|
||||
{
|
||||
if( !isValid() )
|
||||
{
|
||||
throw new IllegalArgumentException( "There is no valid ItemStack for this PatternIngredient" );
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
public String getFormattedToolTip()
|
||||
{
|
||||
String result = String.valueOf( getCount() ) + ' ' + getName();
|
||||
|
||||
if( !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() )
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import appeng.integration.Integrations;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
@@ -198,7 +199,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 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -33,15 +33,12 @@ import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public abstract class PartSharedItemBus extends PartUpgradeable implements IGridTickable
|
||||
{
|
||||
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 9 );
|
||||
private int adaptorHash = 0;
|
||||
private InventoryAdaptor adaptor;
|
||||
private boolean lastRedstone = false;
|
||||
|
||||
public PartSharedItemBus( final ItemStack is )
|
||||
@@ -102,17 +99,7 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
||||
final TileEntity self = this.getHost().getTile();
|
||||
final TileEntity target = this.getTileEntity( self, self.getPos().offset( this.getSide().getFacing() ) );
|
||||
|
||||
final int newAdaptorHash = Platform.generateTileHash( target );
|
||||
|
||||
if( this.adaptorHash == newAdaptorHash && newAdaptorHash != 0 )
|
||||
{
|
||||
return this.adaptor;
|
||||
}
|
||||
|
||||
this.adaptorHash = newAdaptorHash;
|
||||
this.adaptor = InventoryAdaptor.getAdaptor( target, this.getSide().getFacing().getOpposite() );
|
||||
|
||||
return this.adaptor;
|
||||
return InventoryAdaptor.getAdaptor( target, this.getSide().getFacing().getOpposite() );
|
||||
}
|
||||
|
||||
private TileEntity getTileEntity( final TileEntity self, final BlockPos pos )
|
||||
|
||||
@@ -22,6 +22,7 @@ package appeng.parts.misc;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -402,6 +403,25 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
|
||||
}
|
||||
|
||||
private int createHandlerHash( TileEntity target )
|
||||
{
|
||||
if( target == null )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
final EnumFacing targetSide = this.getSide().getFacing().getOpposite();
|
||||
if( target.hasCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
final IItemHandler itemHandler = target.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, targetSide );
|
||||
if( handler != null )
|
||||
{
|
||||
return Objects.hash( target, itemHandler, itemHandler.getSlots() );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public MEInventoryHandler getInternalHandler()
|
||||
{
|
||||
if( this.cached )
|
||||
@@ -414,9 +434,9 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
this.cached = true;
|
||||
final TileEntity self = this.getHost().getTile();
|
||||
final TileEntity target = self.getWorld().getTileEntity( self.getPos().offset( this.getSide().getFacing() ) );
|
||||
final int newHandlerHash = Platform.generateTileHash( target );
|
||||
final int newHandlerHash = createHandlerHash( target );
|
||||
|
||||
if( this.handlerHash == newHandlerHash && this.handlerHash != 0 )
|
||||
if( newHandlerHash != 0 && newHandlerHash == this.handlerHash )
|
||||
{
|
||||
return this.handler;
|
||||
}
|
||||
@@ -603,5 +623,4 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
return MODELS_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ import appeng.util.Platform;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperChainedItemHandler;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
@@ -83,8 +84,9 @@ import appeng.util.item.AEItemStack;
|
||||
public class TileMolecularAssembler extends AENetworkInvTile implements IUpgradeableHost, IConfigManagerHost, IGridTickable, ICraftingMachine, IPowerChannelState
|
||||
{
|
||||
private final InventoryCrafting craftingInv;
|
||||
private final AppEngInternalInventory gridInv = new AppEngInternalInventory( this, 9 + 1, 1, new CraftingGridFilter() );
|
||||
private final AppEngInternalInventory gridInv = new AppEngInternalInventory( this, 9 + 1, 1 );
|
||||
private final AppEngInternalInventory patternInv = new AppEngInternalInventory( this, 1, 1 );
|
||||
private final IItemHandler gridInvExt = new WrapperFilteredItemHandler( gridInv, new CraftingGridFilter() );
|
||||
private final IItemHandler internalInv = new WrapperChainedItemHandler( gridInv, patternInv );
|
||||
private final IConfigManager settings;
|
||||
private final UpgradeInventory upgrades;
|
||||
@@ -347,7 +349,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
@Override
|
||||
protected IItemHandler getItemHandlerForSide( EnumFacing side )
|
||||
{
|
||||
return gridInv;
|
||||
return gridInvExt;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -96,6 +96,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
private final AppEngInternalInventory topItemHandler = new AppEngInternalInventory( this, 1, 1 );
|
||||
private final AppEngInternalInventory bottomItemHandler = new AppEngInternalInventory( this, 1, 1 );
|
||||
private final AppEngInternalInventory sideItemHandler = new AppEngInternalInventory( this, 2, 1 );
|
||||
|
||||
private final IItemHandler topItemHandlerExtern;
|
||||
private final IItemHandler bottomItemHandlerExtern;
|
||||
private final IItemHandler sideItemHandlerExtern;
|
||||
|
||||
private final IItemHandlerModifiable inv = new WrapperChainedItemHandler( topItemHandler, bottomItemHandler, sideItemHandler );
|
||||
@@ -112,10 +115,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
this.upgrades = new DefinitionUpgradeInventory( inscriberDefinition, this, this.getUpgradeSlots() );
|
||||
|
||||
final IAEItemFilter filter = new ItemHandlerFilter();
|
||||
topItemHandler.setFilter( filter );
|
||||
bottomItemHandler.setFilter( filter );
|
||||
topItemHandlerExtern = new WrapperFilteredItemHandler( topItemHandler, filter );
|
||||
bottomItemHandlerExtern = new WrapperFilteredItemHandler( bottomItemHandler, filter );
|
||||
sideItemHandlerExtern = new WrapperFilteredItemHandler( sideItemHandler, filter );
|
||||
|
||||
}
|
||||
|
||||
private int getUpgradeSlots()
|
||||
@@ -360,13 +362,13 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
|
||||
final boolean matchA = ( plateA.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateA,
|
||||
recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and...
|
||||
( plateB.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateB,
|
||||
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) );
|
||||
( ( plateB.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateB,
|
||||
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ) );
|
||||
|
||||
final boolean matchB = ( plateB.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateB,
|
||||
recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and...
|
||||
( plateA.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateA,
|
||||
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) );
|
||||
( ( plateA.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateA,
|
||||
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ) );
|
||||
|
||||
if( matchA || matchB )
|
||||
{
|
||||
@@ -501,11 +503,11 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
{
|
||||
if( facing == getUp() )
|
||||
{
|
||||
return topItemHandler;
|
||||
return topItemHandlerExtern;
|
||||
}
|
||||
else if( facing == getUp().getOpposite() )
|
||||
{
|
||||
return bottomItemHandler;
|
||||
return bottomItemHandlerExtern;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -574,7 +576,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
return false;
|
||||
}
|
||||
|
||||
return slot == 1;
|
||||
return inv == topItemHandler || inv == bottomItemHandler || slot == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,8 +46,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -58,7 +56,6 @@ import net.minecraft.network.play.server.SPacketChunkData;
|
||||
import net.minecraft.server.management.PlayerChunkMap;
|
||||
import net.minecraft.server.management.PlayerChunkMapEntry;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -115,7 +112,6 @@ import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
@@ -1342,70 +1338,6 @@ public class Platform
|
||||
}
|
||||
}
|
||||
|
||||
public static int generateTileHash( final TileEntity target )
|
||||
{
|
||||
if( target == null )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hash = target.hashCode();
|
||||
|
||||
if( target.hasCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, null ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if( target instanceof TileEntityChest )
|
||||
{
|
||||
final TileEntityChest chest = (TileEntityChest) target;
|
||||
chest.checkForAdjacentChests();
|
||||
if( chest.adjacentChestZNeg != null )
|
||||
{
|
||||
hash ^= chest.adjacentChestZNeg.hashCode();
|
||||
}
|
||||
else if( chest.adjacentChestZPos != null )
|
||||
{
|
||||
hash ^= chest.adjacentChestZPos.hashCode();
|
||||
}
|
||||
else if( chest.adjacentChestXPos != null )
|
||||
{
|
||||
hash ^= chest.adjacentChestXPos.hashCode();
|
||||
}
|
||||
else if( chest.adjacentChestXNeg != null )
|
||||
{
|
||||
hash ^= chest.adjacentChestXNeg.hashCode();
|
||||
}
|
||||
}
|
||||
else if( target instanceof IInventory )
|
||||
{
|
||||
hash ^= ( (IInventory) target ).getSizeInventory();
|
||||
|
||||
if( target instanceof ISidedInventory )
|
||||
{
|
||||
for( final EnumFacing dir : EnumFacing.VALUES )
|
||||
{
|
||||
|
||||
final int[] sides = ( (ISidedInventory) target ).getSlotsForFace( dir );
|
||||
|
||||
if( sides == null )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
for( final int side : sides )
|
||||
{
|
||||
final int c = ( side << ( offset % 8 ) ) ^ ( 1 << dir.ordinal() );
|
||||
offset++;
|
||||
hash = c + ( hash << 6 ) + ( hash << 16 ) - hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static boolean securityCheck( final GridNode a, final GridNode b )
|
||||
{
|
||||
if( a.getLastSecurityKey() == -1 && b.getLastSecurityKey() == -1 )
|
||||
|
||||
Reference in New Issue
Block a user