mirror of
https://github.com/GTNewHorizons/ThaumicEnergistics.git
synced 2026-10-25 20:32:27 +00:00
Distillation Encoder
Added Distillation Encoder Added pattern handler Working on GUI
This commit is contained in:
1 parent
58b3cdd5fb
commit
383293c0e7
19 files changed
+637
-14
No files matched your search
+6
-1
@@ -1,4 +1,9 @@
|
||||
12/29/2015 0.10.0.0 - Beta
|
||||
12/30/2015 0.10.0.0 - Beta
|
||||
Added Distillation Encoder
|
||||
Added pattern handler
|
||||
Working on GUI
|
||||
|
||||
12/29/2015 0.10.0.0 - Beta
|
||||
Began integrating essentia into crafting system.
|
||||
Added "Essentia" item.
|
||||
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
package thaumicenergistics.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.gui.ThEGuiHandler;
|
||||
import thaumicenergistics.registries.BlockEnum;
|
||||
import thaumicenergistics.texture.BlockTextureManager;
|
||||
import thaumicenergistics.tileentities.TileDistillationEncoder;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockDistillationEncoder
|
||||
extends AbstractBlockAEWrenchable
|
||||
{
|
||||
public BlockDistillationEncoder()
|
||||
{
|
||||
// Call super with material machine (iron)
|
||||
super( Material.iron );
|
||||
|
||||
// Basic hardness
|
||||
this.setHardness( 1.0f );
|
||||
|
||||
// Sound of metal
|
||||
this.setStepSound( Block.soundTypeMetal );
|
||||
|
||||
// Place in the ThE creative tab
|
||||
this.setCreativeTab( ThaumicEnergistics.ThETab );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean onBlockActivated( final World world, final int x, final int y, final int z, final EntityPlayer player )
|
||||
{
|
||||
// Launch the gui.
|
||||
ThEGuiHandler.launchGui( ThEGuiHandler.DISTILLATION_ENCODER, player, world, x, y, z );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the tile entity associated with the block.
|
||||
*/
|
||||
@Override
|
||||
public TileEntity createNewTileEntity( final World world, final int metaData )
|
||||
{
|
||||
return new TileDistillationEncoder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the standard block icon.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIcon( final int side, final int meta )
|
||||
{
|
||||
// Face?
|
||||
if( side == ForgeDirection.OPPOSITES[meta] )
|
||||
{
|
||||
// Face texture
|
||||
return BlockTextureManager.DISTILLATION_ENCODER.getTextures()[1];
|
||||
}
|
||||
|
||||
// Top or bottom?
|
||||
if( ( ForgeDirection.VALID_DIRECTIONS[side] == ForgeDirection.UP )
|
||||
|| ( ForgeDirection.VALID_DIRECTIONS[side] == ForgeDirection.DOWN ) )
|
||||
{
|
||||
// Bottom texture
|
||||
return BlockTextureManager.DISTILLATION_ENCODER.getTextures()[2];
|
||||
|
||||
}
|
||||
|
||||
// Sides
|
||||
return BlockTextureManager.DISTILLATION_ENCODER.getTextures()[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the unlocalized name of the block.
|
||||
*/
|
||||
@Override
|
||||
public String getUnlocalizedName()
|
||||
{
|
||||
return BlockEnum.DISTILLATION_ENCODER.getUnlocalizedName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is opaque.
|
||||
*/
|
||||
@Override
|
||||
public final boolean isOpaqueCube()
|
||||
{
|
||||
// Occlude adjoining faces.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is solid.
|
||||
*/
|
||||
@Override
|
||||
public final boolean isSideSolid( final IBlockAccess world, final int x, final int y, final int z, final ForgeDirection side )
|
||||
{
|
||||
// This is a solid cube
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy( final World world, final int x, final int y, final int z, final EntityLivingBase player, final ItemStack itemStack )
|
||||
{
|
||||
// Set the metadata to up
|
||||
world.setBlockMetadataWithNotify( x, y, z, 0, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Taken care of by texture manager
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public final void registerBlockIcons( final IIconRegister register )
|
||||
{
|
||||
// Ignored
|
||||
}
|
||||
|
||||
/**
|
||||
* Normal renderer.
|
||||
*/
|
||||
@Override
|
||||
public final boolean renderAsNormalBlock()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rotateBlock( final World world, final int x, final int y, final int z, final ForgeDirection side )
|
||||
{
|
||||
// Get and increment the meta data
|
||||
int metaData = world.getBlockMetadata( x, y, z ) + 1;
|
||||
|
||||
// Bounds check
|
||||
if( metaData >= ForgeDirection.VALID_DIRECTIONS.length )
|
||||
{
|
||||
metaData = 0;
|
||||
}
|
||||
|
||||
// Set the meta data
|
||||
world.setBlockMetadataWithNotify( x, y, z, metaData, 3 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -90,15 +90,20 @@ public class BlockKnowledgeInscriber
|
||||
@Override
|
||||
public IIcon getIcon( final int side, final int meta )
|
||||
{
|
||||
// Face?
|
||||
if( side == ForgeDirection.OPPOSITES[meta] )
|
||||
{
|
||||
// Face(top) texture
|
||||
// Face texture
|
||||
return BlockTextureManager.KNOWLEDGE_INSCRIBER.getTextures()[1];
|
||||
}
|
||||
else if( side == meta )
|
||||
|
||||
// Top or bottom?
|
||||
if( ( ForgeDirection.VALID_DIRECTIONS[side] == ForgeDirection.UP )
|
||||
|| ( ForgeDirection.VALID_DIRECTIONS[side] == ForgeDirection.DOWN ) )
|
||||
{
|
||||
// Bottom texture
|
||||
return BlockTextureManager.KNOWLEDGE_INSCRIBER.getTextures()[2];
|
||||
|
||||
}
|
||||
|
||||
// Sides
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package thaumicenergistics.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.items.ItemCraftingAspect;
|
||||
import thaumicenergistics.registries.ItemEnum;
|
||||
import thaumicenergistics.util.DistillationPatternHelper;
|
||||
import thaumicenergistics.util.EffectiveSide;
|
||||
import appeng.api.AEApi;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
public class ContainerDistillationEncoder
|
||||
extends ContainerWithPlayerInventory
|
||||
{
|
||||
/**
|
||||
* Y position for the player and hotbar inventory.
|
||||
*/
|
||||
private static final int PLAYER_INV_POSITION_Y = 152, HOTBAR_INV_POSITION_Y = PLAYER_INV_POSITION_Y + 58;
|
||||
|
||||
/**
|
||||
* Player who opened the GUI.
|
||||
*/
|
||||
protected EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param player
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
*/
|
||||
public ContainerDistillationEncoder( final EntityPlayer player, final World world, final int x, final int y, final int z )
|
||||
{
|
||||
// Set the player
|
||||
this.player = player;
|
||||
|
||||
// Bind to the players inventory
|
||||
this.bindPlayerInventory( player.inventory, PLAYER_INV_POSITION_Y, HOTBAR_INV_POSITION_Y );
|
||||
}
|
||||
|
||||
/**
|
||||
* Can interact with any real player.
|
||||
*/
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
return !( player instanceof FakePlayer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick( final int slotID, final int buttonPressed, final int flag, final EntityPlayer player )
|
||||
{
|
||||
// Is this client side?
|
||||
if( EffectiveSide.isClientSide() )
|
||||
{
|
||||
// Do nothing.
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: Debug code
|
||||
// Create a new pattern
|
||||
Optional<ItemStack> oStack = AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 );
|
||||
if( oStack.isPresent() )
|
||||
{
|
||||
DistillationPatternHelper h = new DistillationPatternHelper();
|
||||
h.input = new ItemStack( Item.getItemById( 331 ) );
|
||||
|
||||
h.output = ItemEnum.CRAFTING_ASPECT.getStack( 2 );
|
||||
ItemCraftingAspect.setAspect( h.output, Aspect.ENERGY );
|
||||
|
||||
ItemStack pattern = oStack.get();
|
||||
h.writeToPattern( pattern );
|
||||
|
||||
this.player.inventory.addItemStackToInventory( pattern );
|
||||
this.player.inventory.markDirty();
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot( final EntityPlayer player, final int slotNumber )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package thaumicenergistics.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import thaumicenergistics.container.ContainerDistillationEncoder;
|
||||
import thaumicenergistics.gui.abstraction.AbstractGuiBase;
|
||||
import thaumicenergistics.registries.ThEStrings;
|
||||
import thaumicenergistics.texture.GuiTextureManager;
|
||||
|
||||
public class GuiDistillationEncoder
|
||||
extends AbstractGuiBase
|
||||
{
|
||||
/**
|
||||
* Gui size.
|
||||
*/
|
||||
private static final int GUI_WIDTH = 176, GUI_HEIGHT = 234;
|
||||
|
||||
/**
|
||||
* Position of the title string.
|
||||
*/
|
||||
private static final int TITLE_POS_X = 6, TITLE_POS_Y = 6;
|
||||
|
||||
/**
|
||||
* Title of the gui.
|
||||
*/
|
||||
private final String title;
|
||||
|
||||
public GuiDistillationEncoder( final EntityPlayer player, final World world, final int x, final int y, final int z )
|
||||
{
|
||||
// Call super
|
||||
super( new ContainerDistillationEncoder( player, world, x, y, z ) );
|
||||
|
||||
// Set the title
|
||||
this.title = ThEStrings.Block_DistillationEncoder.getLocalized();
|
||||
|
||||
// Set the GUI size
|
||||
this.xSize = GUI_WIDTH;
|
||||
this.ySize = GUI_HEIGHT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the background.
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer( final float alpha, final int mouseX, final int mouseY )
|
||||
{
|
||||
// Full white
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
// Bind the encoder gui texture
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture( GuiTextureManager.DISTILLATION_ENCODER.getTexture() );
|
||||
|
||||
// Draw the gui texture
|
||||
this.drawTexturedModalRect( this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize );
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground.
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer( final int mouseX, final int mouseY )
|
||||
{
|
||||
// Draw the title
|
||||
this.fontRendererObj.drawString( this.title, TITLE_POS_X, TITLE_POS_Y, 0 );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onButtonClicked( final GuiButton button, final int mouseButton )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
// Call super
|
||||
super.initGui();
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.api.ICraftingIssuerTerminalHost;
|
||||
import thaumicenergistics.container.ContainerArcaneAssembler;
|
||||
import thaumicenergistics.container.ContainerDistillationEncoder;
|
||||
import thaumicenergistics.container.ContainerEssentiaCell;
|
||||
import thaumicenergistics.container.ContainerEssentiaCellWorkbench;
|
||||
import thaumicenergistics.container.ContainerEssentiaVibrationChamber;
|
||||
@@ -78,6 +79,11 @@ public class ThEGuiHandler
|
||||
*/
|
||||
public static final int AUTO_CRAFTING_CONFIRM = ID_STEP_VALUE * 9;
|
||||
|
||||
/**
|
||||
* ID of the distillation encoder.
|
||||
*/
|
||||
public static final int DISTILLATION_ENCODER = ID_STEP_VALUE * 10;
|
||||
|
||||
/**
|
||||
* Extra data used for some GUI calls.
|
||||
*/
|
||||
@@ -279,6 +285,10 @@ public class ThEGuiHandler
|
||||
// Vibration chamber?
|
||||
case ThEGuiHandler.ESSENTIA_VIBRATION_CHAMBER:
|
||||
return new GuiEssentiaVibrationChamber( player, world, x, y, z );
|
||||
|
||||
// Distillation encoder?
|
||||
case ThEGuiHandler.DISTILLATION_ENCODER:
|
||||
return new GuiDistillationEncoder( player, world, x, y, z );
|
||||
}
|
||||
|
||||
// Is this the priority window?
|
||||
@@ -377,6 +387,10 @@ public class ThEGuiHandler
|
||||
case ThEGuiHandler.ESSENTIA_VIBRATION_CHAMBER:
|
||||
return new ContainerEssentiaVibrationChamber( player, world, x, y, z );
|
||||
|
||||
// Distillation encoder?
|
||||
case ThEGuiHandler.DISTILLATION_ENCODER:
|
||||
return new ContainerDistillationEncoder( player, world, x, y, z );
|
||||
|
||||
}
|
||||
|
||||
// Is this the priority window?
|
||||
|
||||
@@ -8,7 +8,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
@@ -21,8 +20,6 @@ public class ItemCraftingAspect
|
||||
{
|
||||
private static final String NBTKEY_ASPECT = "Aspect";
|
||||
|
||||
public IIcon icon;
|
||||
|
||||
public ItemCraftingAspect()
|
||||
{
|
||||
this.setMaxStackSize( 64 );
|
||||
|
||||
@@ -269,7 +269,7 @@ public class AEPartEssentiaTerminal
|
||||
// Read inventory
|
||||
if( data.hasKey( AEPartEssentiaTerminal.INVENTORY_NBT_KEY ) )
|
||||
{
|
||||
this.inventory.loadFromNBT( data, AEPartEssentiaTerminal.INVENTORY_NBT_KEY );
|
||||
this.inventory.readFromNBT( data, AEPartEssentiaTerminal.INVENTORY_NBT_KEY );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ public class AEPartEssentiaTerminal
|
||||
// Write inventory
|
||||
if( !this.inventory.isEmpty() )
|
||||
{
|
||||
this.inventory.saveToNBT( data, AEPartEssentiaTerminal.INVENTORY_NBT_KEY );
|
||||
this.inventory.writeToNBT( data, AEPartEssentiaTerminal.INVENTORY_NBT_KEY );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package thaumicenergistics.registries;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import thaumicenergistics.blocks.BlockArcaneAssembler;
|
||||
import thaumicenergistics.blocks.BlockDistillationEncoder;
|
||||
import thaumicenergistics.blocks.BlockEssentiaCellWorkbench;
|
||||
import thaumicenergistics.blocks.BlockEssentiaProvider;
|
||||
import thaumicenergistics.blocks.BlockEssentiaVibrationChamber;
|
||||
@@ -22,7 +23,8 @@ public enum BlockEnum
|
||||
ARCANE_ASSEMBLER (ThEStrings.Block_ArcaneAssembler, new BlockArcaneAssembler()),
|
||||
KNOWLEDGE_INSCRIBER (ThEStrings.Block_KnowledgeInscriber, new BlockKnowledgeInscriber()),
|
||||
ESSENTIA_VIBRATION_CHAMBER (ThEStrings.Block_EssentiaVibrationChamber, new BlockEssentiaVibrationChamber(),
|
||||
ItemBlockEssentiaVibrationChamber.class);
|
||||
ItemBlockEssentiaVibrationChamber.class),
|
||||
DISTILLATION_ENCODER (ThEStrings.Block_DistillationEncoder, new BlockDistillationEncoder());
|
||||
|
||||
/**
|
||||
* The block object.
|
||||
|
||||
@@ -23,6 +23,7 @@ public enum ThEStrings
|
||||
Block_ArcaneAssembler ("block.arcane.assembler", true),
|
||||
Block_KnowledgeInscriber ("block.knowledge.inscriber", true),
|
||||
Block_EssentiaVibrationChamber ("block.essentia.vibration.chamber", true),
|
||||
Block_DistillationEncoder ("block.distillation.encoder", true),
|
||||
|
||||
// Parts
|
||||
Part_EssentiaImportBus ("aeparts.essentia.ImportBus", true),
|
||||
|
||||
@@ -2,6 +2,7 @@ package thaumicenergistics.registries;
|
||||
|
||||
import thaumicenergistics.ThaumicEnergistics;
|
||||
import thaumicenergistics.tileentities.TileArcaneAssembler;
|
||||
import thaumicenergistics.tileentities.TileDistillationEncoder;
|
||||
import thaumicenergistics.tileentities.TileEssentiaCellWorkbench;
|
||||
import thaumicenergistics.tileentities.TileEssentiaProvider;
|
||||
import thaumicenergistics.tileentities.TileEssentiaVibrationChamber;
|
||||
@@ -17,7 +18,8 @@ public enum TileEnum
|
||||
CellWorkbench ("TileEssentiaCellWorkbench", TileEssentiaCellWorkbench.class),
|
||||
ArcaneAssembler ("TileArcaneAssembler", TileArcaneAssembler.class),
|
||||
KnowledgeInscriber ("TileKnowledgeInscriber", TileKnowledgeInscriber.class),
|
||||
EssentiaVibrationChamber ("TileEssentiaVibrationChamber", TileEssentiaVibrationChamber.class);
|
||||
EssentiaVibrationChamber ("TileEssentiaVibrationChamber", TileEssentiaVibrationChamber.class),
|
||||
DistillationInscriber ("TileDistillationInscriber", TileDistillationEncoder.class);
|
||||
|
||||
/**
|
||||
* Unique ID of the tile entity
|
||||
|
||||
@@ -44,7 +44,10 @@ public enum BlockTextureManager
|
||||
KNOWLEDGE_INSCRIBER (TextureTypes.Block, new String[] { "knowledge.inscriber.side", "knowledge.inscriber.top", "knowledge.inscriber.bottom" }),
|
||||
|
||||
ESSENTIA_VIBRATION_CHAMBER (TextureTypes.Block, new String[] { "e.vibration.input", "e.vibration.face.off", "e.vibration.face.ignis",
|
||||
"e.vibration.face.potentia", });
|
||||
"e.vibration.face.potentia" }),
|
||||
|
||||
DISTILLATION_ENCODER (TextureTypes.Block,
|
||||
new String[] { "knowledge.inscriber.side", "distillation.encoder.face", "knowledge.inscriber.bottom" });
|
||||
|
||||
private enum TextureTypes
|
||||
{
|
||||
|
||||
@@ -14,7 +14,8 @@ public enum GuiTextureManager
|
||||
CELL_WORKBENCH ("essentia.cell.workbench"),
|
||||
ARCANE_ASSEMBLER ("arcane.assembler"),
|
||||
KNOWLEDGE_INSCRIBER ("knowledge.inscriber"),
|
||||
ESSENTIA_VIBRATION_CHAMBER ("essentia.vibration.chamber");
|
||||
ESSENTIA_VIBRATION_CHAMBER ("essentia.vibration.chamber"),
|
||||
DISTILLATION_ENCODER ("distillation.encoder");
|
||||
|
||||
private ResourceLocation texture;
|
||||
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
package thaumicenergistics.tileentities;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import thaumicenergistics.items.ItemCraftingAspect;
|
||||
import thaumicenergistics.util.IInventoryUpdateReceiver;
|
||||
import thaumicenergistics.util.PrivateInventory;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
|
||||
public class TileDistillationEncoder
|
||||
extends TileEntity
|
||||
implements IInventoryUpdateReceiver
|
||||
{
|
||||
/**
|
||||
* NBT Keys
|
||||
*/
|
||||
private static String NBTKEY_INVENTORY = "inventory";
|
||||
|
||||
/**
|
||||
* Slot counts
|
||||
*/
|
||||
public static int SLOT_SOURCE_ASPECTS_COUNT = 6,
|
||||
SLOT_SAVED_ASPECT_COUNT = 1,
|
||||
SLOT_PATTERNS_COUNT = 2,
|
||||
SLOT_INPUT_ITEM_COUNT = 1,
|
||||
SLOT_TOTAL_COUNT = SLOT_INPUT_ITEM_COUNT + SLOT_SOURCE_ASPECTS_COUNT + SLOT_SAVED_ASPECT_COUNT + SLOT_PATTERNS_COUNT;
|
||||
/**
|
||||
* Slot ID's
|
||||
*/
|
||||
public static int SLOT_SOURCE_ITEM = 0,
|
||||
SLOT_EMPTY_PATTERNS = 1,
|
||||
SLOT_ENCODED_PATTERN = 2,
|
||||
SLOT_SOURCE_ASPECTS = 3,
|
||||
SLOT_SAVED_ASPECT = SLOT_SOURCE_ASPECTS + SLOT_SOURCE_ASPECTS_COUNT;
|
||||
|
||||
/**
|
||||
* Stores the inventory for this tile.
|
||||
*/
|
||||
private PrivateInventory internalInventory = new PrivateInventory( "distillation.inscriber", SLOT_TOTAL_COUNT, 64, this )
|
||||
{
|
||||
@Override
|
||||
public boolean isItemValidForSlot( final int slotId, final ItemStack itemStack )
|
||||
{
|
||||
// Can always clear a slot
|
||||
if( itemStack == null )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Empty pattern slot?
|
||||
if( slotId == SLOT_EMPTY_PATTERNS )
|
||||
{
|
||||
return( itemStack.getItem() instanceof ItemEncodedPattern );
|
||||
}
|
||||
|
||||
// Encoded pattern slot?
|
||||
if( slotId == SLOT_ENCODED_PATTERN )
|
||||
{
|
||||
return( itemStack.getItem() instanceof ItemEncodedPattern );
|
||||
}
|
||||
|
||||
// Aspect slot?
|
||||
if( ( slotId >= SLOT_SOURCE_ASPECTS ) && ( slotId <= SLOT_SAVED_ASPECT ) )
|
||||
{
|
||||
return( itemStack.getItem() instanceof ItemCraftingAspect );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public TileDistillationEncoder()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the inscriber's inventory.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public IInventory getInventory()
|
||||
{
|
||||
return this.internalInventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if there is a pattern to encode onto.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean hasPattern()
|
||||
{
|
||||
// Is there anything in the pattern slots?
|
||||
return( ( this.internalInventory.slots[SLOT_ENCODED_PATTERN] != null )
|
||||
|| ( this.internalInventory.slots[SLOT_EMPTY_PATTERNS] != null ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the internal inventory changes
|
||||
*/
|
||||
@Override
|
||||
public void onInventoryChanged( final IInventory sourceInventory )
|
||||
{
|
||||
// Mark the tile dirty
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read tile state from NBT.
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
// Call super
|
||||
super.readFromNBT( data );
|
||||
|
||||
// Has saved inventory?
|
||||
if( data.hasKey( NBTKEY_INVENTORY ) )
|
||||
{
|
||||
this.internalInventory.readFromNBT( data, NBTKEY_INVENTORY );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Write tile state to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
// Call super
|
||||
super.writeToNBT( data );
|
||||
|
||||
// Write the inventory
|
||||
this.internalInventory.writeToNBT( data, NBTKEY_INVENTORY );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package thaumicenergistics.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
|
||||
public class DistillationPatternHelper
|
||||
{
|
||||
/**
|
||||
* NBT Keys
|
||||
*/
|
||||
private static final String NBTKEY_AE_IN = "in",
|
||||
NBTKEY_AE_OUT = "out",
|
||||
NBTKEY_AE_ISCRAFTING = "crafting",
|
||||
NBTKEY_AE_CAN_SUB = "substitute";
|
||||
|
||||
/**
|
||||
* Output of the pattern.
|
||||
* Must be ItemCraftingAspect patterns.
|
||||
*/
|
||||
public ItemStack output = null;
|
||||
|
||||
/**
|
||||
* Input of the pattern.
|
||||
*/
|
||||
public ItemStack input = null;
|
||||
|
||||
/**
|
||||
* Loads the values from the pattern
|
||||
*
|
||||
* @param pattern
|
||||
*/
|
||||
public void loadFromPattern( final ItemStack pattern )
|
||||
{
|
||||
// Reset
|
||||
this.reset();
|
||||
|
||||
if( !pattern.hasTagCompound() )
|
||||
{
|
||||
// Nothing to load
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the NBT tag
|
||||
NBTTagCompound data = pattern.getTagCompound();
|
||||
|
||||
// Get the input and output list
|
||||
NBTTagList inTags = data.getTagList( NBTKEY_AE_IN, NBT.TAG_COMPOUND );
|
||||
NBTTagList outTags = data.getTagList( NBTKEY_AE_OUT, NBT.TAG_COMPOUND );
|
||||
|
||||
// Empty check
|
||||
if( ( outTags.tagCount() < 1 ) || ( inTags.tagCount() < 1 ) )
|
||||
{
|
||||
// Nothing to load.
|
||||
return;
|
||||
}
|
||||
|
||||
// Read the input and output
|
||||
this.output = ItemStack.loadItemStackFromNBT( outTags.getCompoundTagAt( 0 ) );
|
||||
this.input = ItemStack.loadItemStackFromNBT( inTags.getCompoundTagAt( 0 ) );
|
||||
|
||||
// Null check
|
||||
if( ( this.input == null ) || ( this.output == null ) )
|
||||
{
|
||||
this.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the helper.
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
this.output = null;
|
||||
this.input = null;
|
||||
}
|
||||
|
||||
public void writeToPattern( final ItemStack pattern )
|
||||
{
|
||||
// Check the input & output
|
||||
if( ( this.input == null ) || ( this.output == null ) )
|
||||
{
|
||||
// No input or output
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a new tag
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
// Write the input
|
||||
NBTTagList inTags = new NBTTagList();
|
||||
inTags.appendTag( this.input.writeToNBT( new NBTTagCompound() ) );
|
||||
|
||||
// Write the outputs
|
||||
NBTTagList outTags = new NBTTagList();
|
||||
outTags.appendTag( this.output.writeToNBT( new NBTTagCompound() ) );
|
||||
|
||||
// Write the basics
|
||||
data.setBoolean( NBTKEY_AE_CAN_SUB, false );
|
||||
data.setBoolean( NBTKEY_AE_ISCRAFTING, false );
|
||||
|
||||
// Write the lists
|
||||
data.setTag( NBTKEY_AE_IN, inTags );
|
||||
data.setTag( NBTKEY_AE_OUT, outTags );
|
||||
|
||||
// Save into the item
|
||||
pattern.setTagCompound( data );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -184,7 +184,7 @@ public class PrivateInventory
|
||||
return true;
|
||||
}
|
||||
|
||||
public final void loadFromNBT( final NBTTagCompound data, final String tagName )
|
||||
public final void readFromNBT( final NBTTagCompound data, final String tagName )
|
||||
{
|
||||
// Ensure there is a data tag
|
||||
if( data == null )
|
||||
@@ -233,7 +233,7 @@ public class PrivateInventory
|
||||
{
|
||||
}
|
||||
|
||||
public final void saveToNBT( final NBTTagCompound data, final String tagName )
|
||||
public final void writeToNBT( final NBTTagCompound data, final String tagName )
|
||||
{
|
||||
// Ensure there is a data tag
|
||||
if( data == null )
|
||||
|
||||
@@ -14,6 +14,7 @@ thaumicenergistics.block.essentia.cell.workbench.name=Essentia Cell Workbench
|
||||
thaumicenergistics.block.arcane.assembler.name=Arcane Assembler
|
||||
thaumicenergistics.block.knowledge.inscriber.name=Knowledge Inscriber
|
||||
thaumicenergistics.block.essentia.vibration.chamber.name=Essentia Vibration Chamber
|
||||
thaumicenergistics.block.distillation.encoder.name=Distillation Encoder
|
||||
|
||||
#Cable parts
|
||||
thaumicenergistics.aeparts.essentia.ImportBus.name=Essentia Import Bus
|
||||
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
Reference in new issue
Block a user