From 349b124ac3a9a413d053002d7afcc5f5c8afa4d1 Mon Sep 17 00:00:00 2001 From: mDiyo Date: Tue, 1 Oct 2013 19:44:04 -0700 Subject: [PATCH] Smeltery broken into components --- src/appeng/api/Blocks.java | 67 +++++ src/appeng/api/DimentionalCoord.java | 58 ++++ src/appeng/api/IAEItemStack.java | 175 ++++++++++++ src/appeng/api/IAETagCompound.java | 33 +++ src/appeng/api/IAppEngApi.java | 161 +++++++++++ src/appeng/api/IAppEngGrinderRecipe.java | 45 +++ src/appeng/api/ICellHandler.java | 25 ++ src/appeng/api/ICellRegistry.java | 31 ++ src/appeng/api/IExternalStorageHandler.java | 27 ++ src/appeng/api/IExternalStorageRegistry.java | 22 ++ src/appeng/api/IGridCacheRegistry.java | 24 ++ src/appeng/api/IGrinderRecipeManager.java | 32 +++ src/appeng/api/IItemComparisionProvider.java | 25 ++ src/appeng/api/IItemComparison.java | 10 + src/appeng/api/IItemList.java | 32 +++ src/appeng/api/ILocateableRegistry.java | 15 + .../api/ISpecialComparisonRegistry.java | 24 ++ src/appeng/api/IWirelessTermHandler.java | 49 ++++ src/appeng/api/IWirelessTermRegistery.java | 38 +++ src/appeng/api/Items.java | 36 +++ src/appeng/api/Materials.java | 58 ++++ src/appeng/api/README.txt | 46 +++ src/appeng/api/TileRef.java | 60 ++++ src/appeng/api/Util.java | 230 +++++++++++++++ src/appeng/api/WorldCoord.java | 132 +++++++++ src/appeng/api/config/ActionItems.java | 17 ++ src/appeng/api/config/CondenserOuput.java | 19 ++ src/appeng/api/config/EnableDisable.java | 18 ++ src/appeng/api/config/FullnessMode.java | 19 ++ src/appeng/api/config/FuzzyMode.java | 27 ++ src/appeng/api/config/IConfigEnum.java | 11 + .../api/config/InterfaceBlockingMode.java | 17 ++ .../api/config/InterfaceCraftingMode.java | 17 ++ src/appeng/api/config/ItemFlow.java | 18 ++ src/appeng/api/config/ListMode.java | 18 ++ src/appeng/api/config/MatchingMode.java | 17 ++ src/appeng/api/config/OperationMode.java | 18 ++ src/appeng/api/config/PowerUnits.java | 19 ++ src/appeng/api/config/RedstoneModeInput.java | 20 ++ .../api/config/RedstoneModeInputOnOff.java | 19 ++ src/appeng/api/config/RedstoneModeOutput.java | 18 ++ src/appeng/api/config/SearchBoxMode.java | 22 ++ src/appeng/api/config/SortDir.java | 18 ++ src/appeng/api/config/SortOrder.java | 20 ++ src/appeng/api/config/StackModeInput.java | 18 ++ src/appeng/api/config/StackModeOutput.java | 20 ++ src/appeng/api/config/TransferDir.java | 18 ++ src/appeng/api/config/ViewItems.java | 19 ++ src/appeng/api/events/AEWorldEvent.java | 17 ++ src/appeng/api/events/GridErrorEvent.java | 18 ++ .../api/events/GridPatternUpdateEvent.java | 22 ++ .../api/events/GridStorageUpdateEvent.java | 22 ++ .../api/events/GridTileConnectivityEvent.java | 22 ++ src/appeng/api/events/GridTileLoadEvent.java | 22 ++ .../api/events/GridTileUnloadEvent.java | 22 ++ .../api/events/LocateableEventAnnounce.java | 25 ++ .../api/events/MultiBlockUpdateEvent.java | 22 ++ .../api/exceptions/AppEngException.java | 12 + .../AppEngTileMissingException.java | 30 ++ .../api/integration/IBeeComparison.java | 20 ++ .../api/me/items/IAEChargeableItem.java | 25 ++ src/appeng/api/me/items/IAEWrench.java | 9 + .../api/me/items/IAssemblerPatternItem.java | 8 + .../api/me/items/ILocationPatternItem.java | 7 + src/appeng/api/me/items/IMEPatternItem.java | 9 + src/appeng/api/me/items/IMemoryCard.java | 40 +++ src/appeng/api/me/items/IStorageCell.java | 48 ++++ .../api/me/items/IStorageComponent.java | 21 ++ src/appeng/api/me/tiles/IAssemblerMB.java | 20 ++ .../me/tiles/IAssemblerPatternProvider.java | 11 + src/appeng/api/me/tiles/ICellContainer.java | 24 ++ src/appeng/api/me/tiles/ICellProvider.java | 23 ++ src/appeng/api/me/tiles/IColoredMETile.java | 36 +++ .../api/me/tiles/IConfigureableTile.java | 28 ++ .../api/me/tiles/IConnectionSensitive.java | 11 + .../api/me/tiles/IDirectionalMETile.java | 20 ++ .../api/me/tiles/IExtendedCellProvider.java | 13 + .../api/me/tiles/IFulllyOptionalMETile.java | 11 + src/appeng/api/me/tiles/IGridMachine.java | 13 + src/appeng/api/me/tiles/IGridTeleport.java | 11 + src/appeng/api/me/tiles/IGridTileEntity.java | 49 ++++ src/appeng/api/me/tiles/ILocateable.java | 10 + src/appeng/api/me/tiles/IMEPowerStorage.java | 34 +++ src/appeng/api/me/tiles/INonSignalBlock.java | 9 + src/appeng/api/me/tiles/IOptionalMETile.java | 14 + src/appeng/api/me/tiles/IOrientableTile.java | 26 ++ src/appeng/api/me/tiles/IPriorityTile.java | 17 ++ src/appeng/api/me/tiles/IPushable.java | 30 ++ src/appeng/api/me/tiles/IStorageAware.java | 13 + src/appeng/api/me/tiles/IStorageMonitor.java | 20 ++ src/appeng/api/me/tiles/ITileCable.java | 7 + src/appeng/api/me/tiles/ITileIOCable.java | 30 ++ .../api/me/tiles/ITileInterfaceApi.java | 78 +++++ .../me/tiles/InterfaceCraftingPattern.java | 19 ++ src/appeng/api/me/util/Grid.java | 84 ++++++ src/appeng/api/me/util/IAssemblerCluster.java | 37 +++ src/appeng/api/me/util/IAssemblerPattern.java | 78 +++++ src/appeng/api/me/util/IConfigManager.java | 10 + src/appeng/api/me/util/ICraftRequest.java | 9 + src/appeng/api/me/util/ICraftWatcher.java | 12 + src/appeng/api/me/util/IGridCache.java | 46 +++ src/appeng/api/me/util/IGridInterface.java | 219 ++++++++++++++ src/appeng/api/me/util/ILocationPattern.java | 12 + src/appeng/api/me/util/IMEInventory.java | 77 +++++ .../api/me/util/IMEInventoryHandler.java | 76 +++++ src/appeng/api/me/util/IMEInventoryUtil.java | 19 ++ .../me/util/InterfaceCraftingResponse.java | 13 + src/tconstruct/TConstruct.java | 16 +- src/tconstruct/blocks/CraftingSlab.java | 2 +- .../blocks/GlassBlockConnected.java | 2 +- .../blocks/GlassBlockConnectedMeta.java | 2 +- src/tconstruct/blocks/GlassPaneConnected.java | 2 +- src/tconstruct/blocks/SmelteryBlock.java | 37 +-- src/tconstruct/blocks/TankAirBlock.java | 22 ++ src/tconstruct/blocks/ToolStationBlock.java | 2 +- .../blocks/component/SmelteryComponent.java | 234 +++++++++++++++ .../blocks/component/SmelteryScan.java | 68 +++++ .../blocks/component/TankAirComponent.java | 20 ++ .../blocks/logic/AdaptiveSmelteryLogic.java | 143 ++++++++-- .../blocks/logic/MultiServantLogic.java | 20 +- .../blocks/logic/SmelteryLogic.java | 15 +- src/tconstruct/blocks/logic/TankAirLogic.java | 76 +++++ .../blocks/logic/TowerFurnaceLogic.java | 76 +---- .../client/block/TankAirRender.java | 73 +++++ src/tconstruct/common/TContent.java | 4 +- src/tconstruct/compat/BOP.java | 36 --- src/tconstruct/compat/Tforest.java | 36 --- .../compat/dimensions/dimblacklist.java | 51 ---- src/tconstruct/items/tools/Cleaver.java | 2 +- src/tconstruct/items/tools/Hatchet.java | 2 +- src/tconstruct/items/tools/Mattock.java | 2 +- .../blocks/AdaptiveInventoryLogic.java | 4 +- .../library/blocks/InventoryBlock.java | 14 +- .../library/blocks/InventoryLogic.java | 11 + .../library/component/LogicComponent.java | 28 ++ .../library/component/MultiFluidTank.java | 97 +++++-- .../library/component/SmelteryComponent.java | 125 -------- .../library/component/TankLayerScan.java | 268 ++++++++++-------- src/tconstruct/library/tools/ToolCore.java | 265 ++++++++++------- src/tconstruct/library/util/CoordTuple.java | 24 +- src/tconstruct/library/util/IMasterLogic.java | 2 +- .../library/util/IServantLogic.java | 20 +- src/tconstruct/modifiers/ModDurability.java | 2 +- src/tconstruct/modifiers/TActiveOmniMod.java | 2 +- src/tconstruct/util/TEventHandler.java | 1 + src/tconstruct/util/config/BOPConfig.java | 37 +++ .../util/config/DimensionBlacklist.java | 62 ++++ .../config}/MystImcHandler.java | 2 +- .../util/{ => config}/PHConstruct.java | 2 +- .../util/config/TwilightForestConfig.java | 28 ++ .../util/player/TPlayerHandler.java | 2 +- .../worldgen/OverworldProvider.java | 2 +- src/tconstruct/worldgen/SlimeIslandGen.java | 8 +- src/tconstruct/worldgen/SurfaceOreGen.java | 2 +- .../worldgen/TBaseWorldGenerator.java | 2 +- .../worldgen/TerrainGenEventHandler.java | 2 +- 156 files changed, 4862 insertions(+), 665 deletions(-) create mode 100644 src/appeng/api/Blocks.java create mode 100644 src/appeng/api/DimentionalCoord.java create mode 100644 src/appeng/api/IAEItemStack.java create mode 100644 src/appeng/api/IAETagCompound.java create mode 100644 src/appeng/api/IAppEngApi.java create mode 100644 src/appeng/api/IAppEngGrinderRecipe.java create mode 100644 src/appeng/api/ICellHandler.java create mode 100644 src/appeng/api/ICellRegistry.java create mode 100644 src/appeng/api/IExternalStorageHandler.java create mode 100644 src/appeng/api/IExternalStorageRegistry.java create mode 100644 src/appeng/api/IGridCacheRegistry.java create mode 100644 src/appeng/api/IGrinderRecipeManager.java create mode 100644 src/appeng/api/IItemComparisionProvider.java create mode 100644 src/appeng/api/IItemComparison.java create mode 100644 src/appeng/api/IItemList.java create mode 100644 src/appeng/api/ILocateableRegistry.java create mode 100644 src/appeng/api/ISpecialComparisonRegistry.java create mode 100644 src/appeng/api/IWirelessTermHandler.java create mode 100644 src/appeng/api/IWirelessTermRegistery.java create mode 100644 src/appeng/api/Items.java create mode 100644 src/appeng/api/Materials.java create mode 100644 src/appeng/api/README.txt create mode 100644 src/appeng/api/TileRef.java create mode 100644 src/appeng/api/Util.java create mode 100644 src/appeng/api/WorldCoord.java create mode 100644 src/appeng/api/config/ActionItems.java create mode 100644 src/appeng/api/config/CondenserOuput.java create mode 100644 src/appeng/api/config/EnableDisable.java create mode 100644 src/appeng/api/config/FullnessMode.java create mode 100644 src/appeng/api/config/FuzzyMode.java create mode 100644 src/appeng/api/config/IConfigEnum.java create mode 100644 src/appeng/api/config/InterfaceBlockingMode.java create mode 100644 src/appeng/api/config/InterfaceCraftingMode.java create mode 100644 src/appeng/api/config/ItemFlow.java create mode 100644 src/appeng/api/config/ListMode.java create mode 100644 src/appeng/api/config/MatchingMode.java create mode 100644 src/appeng/api/config/OperationMode.java create mode 100644 src/appeng/api/config/PowerUnits.java create mode 100644 src/appeng/api/config/RedstoneModeInput.java create mode 100644 src/appeng/api/config/RedstoneModeInputOnOff.java create mode 100644 src/appeng/api/config/RedstoneModeOutput.java create mode 100644 src/appeng/api/config/SearchBoxMode.java create mode 100644 src/appeng/api/config/SortDir.java create mode 100644 src/appeng/api/config/SortOrder.java create mode 100644 src/appeng/api/config/StackModeInput.java create mode 100644 src/appeng/api/config/StackModeOutput.java create mode 100644 src/appeng/api/config/TransferDir.java create mode 100644 src/appeng/api/config/ViewItems.java create mode 100644 src/appeng/api/events/AEWorldEvent.java create mode 100644 src/appeng/api/events/GridErrorEvent.java create mode 100644 src/appeng/api/events/GridPatternUpdateEvent.java create mode 100644 src/appeng/api/events/GridStorageUpdateEvent.java create mode 100644 src/appeng/api/events/GridTileConnectivityEvent.java create mode 100644 src/appeng/api/events/GridTileLoadEvent.java create mode 100644 src/appeng/api/events/GridTileUnloadEvent.java create mode 100644 src/appeng/api/events/LocateableEventAnnounce.java create mode 100644 src/appeng/api/events/MultiBlockUpdateEvent.java create mode 100644 src/appeng/api/exceptions/AppEngException.java create mode 100644 src/appeng/api/exceptions/AppEngTileMissingException.java create mode 100644 src/appeng/api/integration/IBeeComparison.java create mode 100644 src/appeng/api/me/items/IAEChargeableItem.java create mode 100644 src/appeng/api/me/items/IAEWrench.java create mode 100644 src/appeng/api/me/items/IAssemblerPatternItem.java create mode 100644 src/appeng/api/me/items/ILocationPatternItem.java create mode 100644 src/appeng/api/me/items/IMEPatternItem.java create mode 100644 src/appeng/api/me/items/IMemoryCard.java create mode 100644 src/appeng/api/me/items/IStorageCell.java create mode 100644 src/appeng/api/me/items/IStorageComponent.java create mode 100644 src/appeng/api/me/tiles/IAssemblerMB.java create mode 100644 src/appeng/api/me/tiles/IAssemblerPatternProvider.java create mode 100644 src/appeng/api/me/tiles/ICellContainer.java create mode 100644 src/appeng/api/me/tiles/ICellProvider.java create mode 100644 src/appeng/api/me/tiles/IColoredMETile.java create mode 100644 src/appeng/api/me/tiles/IConfigureableTile.java create mode 100644 src/appeng/api/me/tiles/IConnectionSensitive.java create mode 100644 src/appeng/api/me/tiles/IDirectionalMETile.java create mode 100644 src/appeng/api/me/tiles/IExtendedCellProvider.java create mode 100644 src/appeng/api/me/tiles/IFulllyOptionalMETile.java create mode 100644 src/appeng/api/me/tiles/IGridMachine.java create mode 100644 src/appeng/api/me/tiles/IGridTeleport.java create mode 100644 src/appeng/api/me/tiles/IGridTileEntity.java create mode 100644 src/appeng/api/me/tiles/ILocateable.java create mode 100644 src/appeng/api/me/tiles/IMEPowerStorage.java create mode 100644 src/appeng/api/me/tiles/INonSignalBlock.java create mode 100644 src/appeng/api/me/tiles/IOptionalMETile.java create mode 100644 src/appeng/api/me/tiles/IOrientableTile.java create mode 100644 src/appeng/api/me/tiles/IPriorityTile.java create mode 100644 src/appeng/api/me/tiles/IPushable.java create mode 100644 src/appeng/api/me/tiles/IStorageAware.java create mode 100644 src/appeng/api/me/tiles/IStorageMonitor.java create mode 100644 src/appeng/api/me/tiles/ITileCable.java create mode 100644 src/appeng/api/me/tiles/ITileIOCable.java create mode 100644 src/appeng/api/me/tiles/ITileInterfaceApi.java create mode 100644 src/appeng/api/me/tiles/InterfaceCraftingPattern.java create mode 100644 src/appeng/api/me/util/Grid.java create mode 100644 src/appeng/api/me/util/IAssemblerCluster.java create mode 100644 src/appeng/api/me/util/IAssemblerPattern.java create mode 100644 src/appeng/api/me/util/IConfigManager.java create mode 100644 src/appeng/api/me/util/ICraftRequest.java create mode 100644 src/appeng/api/me/util/ICraftWatcher.java create mode 100644 src/appeng/api/me/util/IGridCache.java create mode 100644 src/appeng/api/me/util/IGridInterface.java create mode 100644 src/appeng/api/me/util/ILocationPattern.java create mode 100644 src/appeng/api/me/util/IMEInventory.java create mode 100644 src/appeng/api/me/util/IMEInventoryHandler.java create mode 100644 src/appeng/api/me/util/IMEInventoryUtil.java create mode 100644 src/appeng/api/me/util/InterfaceCraftingResponse.java create mode 100644 src/tconstruct/blocks/TankAirBlock.java create mode 100644 src/tconstruct/blocks/component/SmelteryComponent.java create mode 100644 src/tconstruct/blocks/component/SmelteryScan.java create mode 100644 src/tconstruct/blocks/component/TankAirComponent.java create mode 100644 src/tconstruct/blocks/logic/TankAirLogic.java create mode 100644 src/tconstruct/client/block/TankAirRender.java delete mode 100644 src/tconstruct/compat/BOP.java delete mode 100644 src/tconstruct/compat/Tforest.java delete mode 100644 src/tconstruct/compat/dimensions/dimblacklist.java delete mode 100644 src/tconstruct/library/component/SmelteryComponent.java create mode 100644 src/tconstruct/util/config/BOPConfig.java create mode 100644 src/tconstruct/util/config/DimensionBlacklist.java rename src/tconstruct/{compat/mystcraft => util/config}/MystImcHandler.java (96%) rename src/tconstruct/util/{ => config}/PHConstruct.java (99%) create mode 100644 src/tconstruct/util/config/TwilightForestConfig.java diff --git a/src/appeng/api/Blocks.java b/src/appeng/api/Blocks.java new file mode 100644 index 00000000..50ab002b --- /dev/null +++ b/src/appeng/api/Blocks.java @@ -0,0 +1,67 @@ +package appeng.api; + +import net.minecraft.item.ItemStack; + +/** + * Blocks, all of the Blocks in AE. + * DO NOT USE THESE WITHOUT COPYING THEM : ItemStack.copy() - is your friend. + */ + +public class Blocks +{ + // World Gen + public static ItemStack blkQuartzOre; + public static ItemStack blkQuartz; + + // Tech 1 ( non-ME ) + public static ItemStack blkGrinder; + + // Tech 4? ( ME Storage ) + public static ItemStack blkCable_Colored[]; + + public static ItemStack blkAssembler; + public static ItemStack blkController; + public static ItemStack blkDrive; + public static ItemStack blkPatternEncoder; + public static ItemStack blkWireless; + public static ItemStack blkTerminal; + public static ItemStack blkChest; + public static ItemStack blkInterface; + public static ItemStack blkPartitioner; + public static ItemStack blkCraftingTerminal; + public static ItemStack blkStorageBus; + + public static ItemStack blkAssemblerFieldWall; + public static ItemStack blkHeatVent; + public static ItemStack blkCraftingAccelerator; + + public static ItemStack blkInputCablePrecision; + public static ItemStack blkInputCableFuzzy; + public static ItemStack blkInputCableBasic; + + public static ItemStack blkOutputCablePrecision; + public static ItemStack blkOutputCableFuzzy; + public static ItemStack blkOutputCableBasic; + public static ItemStack blkStorageBusFuzzy; + + public static ItemStack blkLevelEmitter; + public static ItemStack blkDarkCable; + public static ItemStack blkIOPort; + public static ItemStack blkCraftingMonitor; + public static ItemStack blkStorageMonitor; + public static ItemStack blkColorlessCable; + public static ItemStack blkColorlessCableCovered; + + public static ItemStack blkTransitionPlane; + public static ItemStack blkCondenser; + public static ItemStack blkEnergyCell; + public static ItemStack blkPowerRelay; + public static ItemStack blkQuantumRing; + public static ItemStack blkQuantumLink; + public static ItemStack blkQuartzGlass; + public static ItemStack blkQuartzLamp; + + // Used internally, best not to mess with this one... + public static ItemStack blkPhantom; + +} diff --git a/src/appeng/api/DimentionalCoord.java b/src/appeng/api/DimentionalCoord.java new file mode 100644 index 00000000..acf17c2b --- /dev/null +++ b/src/appeng/api/DimentionalCoord.java @@ -0,0 +1,58 @@ +package appeng.api; + +import net.minecraft.world.World; + +public class DimentionalCoord extends WorldCoord +{ + private World w; + private int dimId; + + public DimentionalCoord( DimentionalCoord s ) + { + super( s.x, s.y, s.z ); + w = s.w; + dimId = s.dimId; + } + + public DimentionalCoord( World _w, int _x, int _y, int _z ) + { + super(_x, _y, _z); + w = _w; + dimId = _w.provider.dimensionId; + } + + @Override + public DimentionalCoord copy() + { + return new DimentionalCoord( this ); + } + + public boolean isEqual( DimentionalCoord c ) + { + return x == c.x && y == c.y && z == c.z && c.w == this.w; + } + + @Override + public boolean equals(Object obj) + { + if ( obj instanceof DimentionalCoord ) + return isEqual( (DimentionalCoord)obj ); + return false; + } + + @Override + public int hashCode() + { + return super.hashCode() ^ dimId; + } + + public boolean isInWorld(World world) + { + return w == world; + } + + public World getWorld() + { + return w; + } +} diff --git a/src/appeng/api/IAEItemStack.java b/src/appeng/api/IAEItemStack.java new file mode 100644 index 00000000..4b55ab5e --- /dev/null +++ b/src/appeng/api/IAEItemStack.java @@ -0,0 +1,175 @@ +package appeng.api; + +import java.io.DataOutputStream; +import java.io.IOException; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +/** + * An alternate version of ItemStack for AE to keep tabs on things easier, and to support larger storage. + * stackSizes of getItemStack will be capped. + * + * You may hold on to these if you want, just make sure you let go of them when your not using them. + * + * Don't Implement. + * + * Construct with Util.createItemStack( ItemStack ) + * + */ +public interface IAEItemStack +{ + /** + * seriously? + * @return the item id of the requested item. + */ + public int getItemID(); + + /** + * the item's damage. + * @return + */ + public int getItemDamage(); + + /** + * obtain the NBT Data for the item. + * @return + */ + public IAETagCompound getTagCompound(); + + /** + * creates a standard MC ItemStack for the item. + * @return new itemstack + */ + public ItemStack getItemStack(); + + /** + * create a AE Item clone. + * @return the copy. + */ + public IAEItemStack copy(); + + /** + * number of items in the stack. + * @return basically ItemStack.stackSize + */ + public long getStackSize(); + + /** + * changes the number of items in the stack. + * @param basically, ItemStack.stackSize = N + */ + public void setStackSize( long stackSize ); + + /** + * Same as getStackSize, but for requestable items. ( LP ) + * @return basically itemStack.stackSize but for requestable items. + */ + long getCountRequestable(); + + /** + * Same as setStackSize, but for requestable items. ( LP ) + * @return basically itemStack.stackSize = N but for setStackSize items. + */ + void setCountRequestable(long countRequestable); + + /** + * true, if the item can be crafted. + * @return true, if it can be crafted. + */ + boolean isCraftable(); + + /** + * change weather the item can be crafted. + * @param isCraftable + */ + void setCraftable(boolean isCraftable); + + /** + * basically itemid and damage in one number.. + * @return + */ + int getDef(); + + /** + * clears, requsetable, craftable, and stack sizes. + */ + public void reset(); + + /** + * returns true, if the item can be crafted, requested, or extracted. + * @return isThisRecordMeaningful + */ + boolean isMeaninful(); + + /** + * is there NBT Data for this item? + * @return if there is. + */ + boolean hasTagCompound(); + + /** + * Combines two IAEItemStacks via addition. + * @param option, to add to the current one. + */ + void add(IAEItemStack option); + + /** + * Adds more to the stack size... + * @param i + */ + void incStackSize(long i); + + /** + * removes some from the stack size. + */ + void decStackSize(long i); + + /** + * adds items to the requestable + * @param i + */ + void incCountRequestable(long i); + + /** + * removes items from the requsetable + * @param i + */ + void decCountRequestable(long i); + + /** + * quick way to get access to the MC Item Definition. + * @return + */ + Item getItem(); + + /** + * write to a NBTTagCompound. + * @param i + */ + void writeToNBT(NBTTagCompound i); + + /** + * Compare a IAEItemStack to another AEItemStack or a ItemStack. + * @param obj + * @return true if they are the same. + */ + @Override + public boolean equals(Object obj); + + /** + * Compare the Ore Dictionary ID for this to another item. + * @param oreID + * @return + */ + public boolean sameOre( Object oreID ); + + /** + * Slower for disk saving, but smaller/more efficient for packets. + * @param data + * @throws IOException + */ + public void writeToPacket(DataOutputStream data) throws IOException; + +} diff --git a/src/appeng/api/IAETagCompound.java b/src/appeng/api/IAETagCompound.java new file mode 100644 index 00000000..c7c48c7c --- /dev/null +++ b/src/appeng/api/IAETagCompound.java @@ -0,0 +1,33 @@ +package appeng.api; + +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; + +/** + * Don't cast this... either compare with it, or copy it. + * + * Don't Implement. + */ +public interface IAETagCompound { + + /** + * Create a copy ( the copy will not be a IAETagCompount, it will be a NBTTagCompound. ) + * @return + */ + NBTTagCompound clone(); + + /** + * compare to other NBTTagCompounds or IAETagCompounds + * @param a + * @return true, if they are the same. + */ + @Override + boolean equals( Object a ); + + /** + * returns the special comparison for this tag. + * @return + */ + IItemComparison getSpecialComparison(); + +} diff --git a/src/appeng/api/IAppEngApi.java b/src/appeng/api/IAppEngApi.java new file mode 100644 index 00000000..b65d2659 --- /dev/null +++ b/src/appeng/api/IAppEngApi.java @@ -0,0 +1,161 @@ +package appeng.api; + +import appeng.api.me.items.IMemoryCard; +import appeng.api.me.tiles.IColoredMETile; +import appeng.api.me.util.IAssemblerPattern; +import appeng.api.me.util.IMEInventory; +import appeng.api.me.util.IMEInventoryUtil; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.World; + +public interface IAppEngApi { + + /** + * Attempts to paint the block at the specified coords, the specified color, colors are based off of IColoredMETile.Colors + * @param world + * @param x + * @param y + * @param z + * @param color + * @return if the block was painted, or not you can use this to damage your item if you want. + */ + boolean paintBlock(World world, int x, int y, int z, int color); + + /** + * Add new Grid Caches for use during run time, only use during loading phase. + * @return + */ + IGridCacheRegistry getGridCacheRegistry(); + + /** + * Add additional storage bus handlers to improve interplay with mod blocks that contains special inventories that function unlike vanilla chests. + * AE uses this internally for barrels, dsu's, quantum chests, AE Networks and more. * + * @return IExternalStorageRegistry + */ + IExternalStorageRegistry getExternalStorageRegistry(); + + /** + * Add additional special comparison functionality, AE Uses this internally for Bees. + * @return ISpecialComparisonRegistry + */ + ISpecialComparisonRegistry getSpecialComparsonRegistry(); + + /** + * gives you access to extractItemsByRecipe, other then this theres not much use for this. + * @param mei + * @return + */ + IMEInventoryUtil getIMEInventoryUtil(IMEInventory mei); + + /** + * Lets you register your items as wireless terminals + * @return + */ + IWirelessTermRegistery getWirelessRegistry(); + + /** + * return an locateable object by its serial + * used internally by AE for QNBs / Network Controllers + * @param serial + * @return + */ + Object getLocateableBySerial(Long serial); + + /** + * creates a new instance of IAEItemStack from a MC ItemStack + * @param is + * @return + */ + IAEItemStack createItemStack(ItemStack is); + + /** + * Creates a new instance of IItemList + * @return + */ + IItemList createItemList(); + + /** + * Allows you to register new cell types, these will function in drives + * @return + */ + ICellRegistry getCellRegistry(); + + /** + * Manage grinder recipes via API + * @return + */ + IGrinderRecipeManager getGrinderRecipeManage(); + + /** + * get access to the locatable registry + * @return + */ + ILocateableRegistry getLocateableRegistry(); + + /** + * a simple wrapper around the AEItemStack version on IMEInventory + * @param inv + * @param is + * @return + */ + ItemStack addItemsToInv(IMEInventory inv, ItemStack is); + + /** + * a simple wrapper around the AEItemStack version on IMEInventory + * @param inv + * @param is + * @return + */ + ItemStack extractItems(IMEInventory inv, ItemStack is); + + /** + * Blacklist this item from vanilla AE Terminals / IStorageCell + * @param itemID + * @param meta - if you use OreDictionary.WILDCARD_VALUE it will blacklist the entire itemID. + */ + void addBasicBlackList(int itemID, int meta); + + /** + * Acquire the inventory for a IStorageCell + * @param i + * @return + */ + IMEInventory getBasicCell(ItemStack i); + + /** + * checks if the item is a basic storage cell. + * @param i + * @return + */ + Boolean isBasicCell(ItemStack i); + + /** + * gives you access to assembler pattern inventories. + * @param i + * @return + */ + IAssemblerPattern getAssemblerPattern(ItemStack i); + + /** + * allows you to check if an item is an assembler pattern. + * @param i + * @return + */ + Boolean isAssemblerPattern(ItemStack i); + + /** + * allows you to check if a pattern is blank. + * @param i + * @return + */ + Boolean isBlankPattern(ItemStack i); + + /** + * gives you the ability to interface with AE Memory Cards. + * @return + */ + IMemoryCard getMemoryCardHandler(); + +} diff --git a/src/appeng/api/IAppEngGrinderRecipe.java b/src/appeng/api/IAppEngGrinderRecipe.java new file mode 100644 index 00000000..b8a3f058 --- /dev/null +++ b/src/appeng/api/IAppEngGrinderRecipe.java @@ -0,0 +1,45 @@ +package appeng.api; + +import net.minecraft.item.ItemStack; + +/** + * Lets you manipulate existing recipes. + */ +public interface IAppEngGrinderRecipe { + + /** + * the current input + * @return input that the grinder will accept. + */ + public ItemStack getInput(); + + /** + * lets you change the grinder recipe by changing its input. + * @param input + */ + public void setInput( ItemStack input ); + + /** + * gets the current output + * @return output that the grinder will produce + */ + public ItemStack getOutput(); + + /** + * allows you to change the output. + * @param output + */ + public void setOutput( ItemStack output ); + + /** + * Energy cost, in turns. + * @return number of turns it takes to produce the output from the input. + */ + public int getEnergyCost(); + + /** + * Allows you to adjust the number of turns + * @param new number of turns to produce output. + */ + public void setEnergyCost(int c); +} diff --git a/src/appeng/api/ICellHandler.java b/src/appeng/api/ICellHandler.java new file mode 100644 index 00000000..e0070b1e --- /dev/null +++ b/src/appeng/api/ICellHandler.java @@ -0,0 +1,25 @@ +package appeng.api; + +import net.minecraft.item.ItemStack; +import appeng.api.me.util.IMEInventoryHandler; + +/** + * Registratio record for a Custom Cell handler. + */ +public interface ICellHandler { + + /** + * return true if the provided item is handled by your cell handler. ( AE May choose to skip this method, and just request a handler ) + * @param is + * @return return true, if getCellHandler will not return null. + */ + boolean isCell( ItemStack is ); + + /** + * return a new IMEHandler for the provided item. + * @param is + * @return if you cannot handle the provided item, return null. + */ + IMEInventoryHandler getCellHandler( ItemStack is ); + +} diff --git a/src/appeng/api/ICellRegistry.java b/src/appeng/api/ICellRegistry.java new file mode 100644 index 00000000..2e609301 --- /dev/null +++ b/src/appeng/api/ICellRegistry.java @@ -0,0 +1,31 @@ +package appeng.api; + +import net.minecraft.item.ItemStack; +import appeng.api.me.util.IMEInventoryHandler; + +/** + * Storage Cell Registry, used for specially implemented cells, if you just want to make a item act like a cell, or new cell with diffrent bytes, then you should probobly consider IStorageCell instead its consideriablly simpler. + */ +public interface ICellRegistry { + + /** + * Register a new handler. + * @param h + */ + void addCellHandler( ICellHandler h ); + + /** + * returns true if the provided item, can be handled by a handler in AE, ( AE May choose to skip this and just get the handler instead. ) + * @param is + * @return returns true, if you can get a InventoryHandler for the item passed. + */ + boolean isCellHandled( ItemStack is ); + + /** + * returns an IMEInventoryHandler for the provided item. + * @param is + * @return new IMEInventoryHandler, or null if there isn't one. + */ + IMEInventoryHandler getHandlerForCell( ItemStack is ); + +} diff --git a/src/appeng/api/IExternalStorageHandler.java b/src/appeng/api/IExternalStorageHandler.java new file mode 100644 index 00000000..be14dcc6 --- /dev/null +++ b/src/appeng/api/IExternalStorageHandler.java @@ -0,0 +1,27 @@ +package appeng.api; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.ForgeDirection; +import appeng.api.me.util.IMEInventory; + +/** + * A Registration for a special storage handler. + * + */ +public interface IExternalStorageHandler { + + /** + * if this can handle the provided inventory, return true. ( Generally skipped by AE, and it just calls getInventory ) + * @param te + * @return true, if it can get a handler via getInventory + */ + boolean canHandle( TileEntity te, ForgeDirection d ); + + /** + * if this can handle the given inventory, return the a IMEInventory implemnting class for it, if not return null + * @param te + * @return HandlerFor Inventory. + */ + IMEInventory getInventory( TileEntity te, ForgeDirection d ); + +} diff --git a/src/appeng/api/IExternalStorageRegistry.java b/src/appeng/api/IExternalStorageRegistry.java new file mode 100644 index 00000000..0f4c6352 --- /dev/null +++ b/src/appeng/api/IExternalStorageRegistry.java @@ -0,0 +1,22 @@ +package appeng.api; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.ForgeDirection; + +public interface IExternalStorageRegistry { + + /** + * A registry for StorageBus interactions + * @param ei + */ + void addExternalStorageInterface( IExternalStorageHandler ei ); + + /** + * returns the handler for a given tile / forge direction. + * @param te + * @param opposite + * @return + */ + IExternalStorageHandler getHandler(TileEntity te, ForgeDirection opposite); + +} diff --git a/src/appeng/api/IGridCacheRegistry.java b/src/appeng/api/IGridCacheRegistry.java new file mode 100644 index 00000000..13e188f5 --- /dev/null +++ b/src/appeng/api/IGridCacheRegistry.java @@ -0,0 +1,24 @@ +package appeng.api; + +import appeng.api.me.util.IGridCache; + +/** + * A registry of grid caches to extend grid functionality. + */ +public interface IGridCacheRegistry { + + /** + * Register a new grid cache for use during operation, must be called during the loading phase. + * @param cl + * @return cache id ( can be used later to ask the grid for you cache. ) + */ + int registerGridCache( Class cl ); + + /** + * requests a new instance of a grid cache for use, used internally + * @param id + * @return + */ + IGridCache[] createCacheInstance(); + +} diff --git a/src/appeng/api/IGrinderRecipeManager.java b/src/appeng/api/IGrinderRecipeManager.java new file mode 100644 index 00000000..16b60830 --- /dev/null +++ b/src/appeng/api/IGrinderRecipeManager.java @@ -0,0 +1,32 @@ +package appeng.api; + +import java.util.List; + +import net.minecraft.item.ItemStack; + +/** + * Lets you manipulate Grinder Recipes, by adding or editing existing ones. + */ +public interface IGrinderRecipeManager { + + /** + * Current list of registered recipes, you can modify this if you want too. + * @return currentlyRegistredRecipes + */ + public List getRecipes(); + + /** + * add a new recipe the easy way, in -> out, how many turns. + * @param in + * @param out + * @param cost + */ + public void addRecipe( ItemStack in, ItemStack out, int cost ); + + /** + * Searches for a recipe for a given input, and returns it. + * @param input + * @return identified recipe, or null + */ + public IAppEngGrinderRecipe getRecipeForInput(ItemStack input); +} diff --git a/src/appeng/api/IItemComparisionProvider.java b/src/appeng/api/IItemComparisionProvider.java new file mode 100644 index 00000000..b93194e0 --- /dev/null +++ b/src/appeng/api/IItemComparisionProvider.java @@ -0,0 +1,25 @@ +package appeng.api; + +import net.minecraft.item.ItemStack; + +/** + * Provider for special comparisons. + * when an item is encountered AE Will request if the comparison function handles the item, by trying to request a IItemComparison class. + */ +public interface IItemComparisionProvider { + + /** + * should return a new IItemComparison, or return null if it dosn't handle the supplied item. + * @param is + * @return IItemComparison, or null + */ + IItemComparison getComparison( ItemStack is ); + + /** + * Simple test for support ( AE generally skips this and calls the above function. ) + * @param stack + * @return true, if getComparison will return a valid IItemComparison Object. + */ + public boolean canHandle( ItemStack stack); + +} diff --git a/src/appeng/api/IItemComparison.java b/src/appeng/api/IItemComparison.java new file mode 100644 index 00000000..4bfc35f9 --- /dev/null +++ b/src/appeng/api/IItemComparison.java @@ -0,0 +1,10 @@ +package appeng.api; + + +public interface IItemComparison { + + public boolean sameAsPrecise( IItemComparison comp); + + public boolean sameAsFuzzy(IItemComparison comp); + +} diff --git a/src/appeng/api/IItemList.java b/src/appeng/api/IItemList.java new file mode 100644 index 00000000..9f722000 --- /dev/null +++ b/src/appeng/api/IItemList.java @@ -0,0 +1,32 @@ +package appeng.api; + +import java.util.Iterator; +import java.util.List; + +import net.minecraft.item.ItemStack; + +/** + * Represents a list of items in AE. + * + * Don't Implement. + * + * Construct with Util.createItemList() + * + */ +public interface IItemList extends Iterable +{ + public void addStorage( IAEItemStack option ); // adds a stack as stored. + public void addCrafting( IAEItemStack option ); // adds a stack as craftable. + public void addRequestable( IAEItemStack option ); // adds a stack as requestable. + public void add( IAEItemStack option ); // adds stack as is. + + IAEItemStack getFirstItem(); + + public List getItems(); + IAEItemStack findItem(IAEItemStack i); + int size(); + + @Override + public Iterator iterator(); + public void setCurrentPriority(int priority); +} diff --git a/src/appeng/api/ILocateableRegistry.java b/src/appeng/api/ILocateableRegistry.java new file mode 100644 index 00000000..8e75cbef --- /dev/null +++ b/src/appeng/api/ILocateableRegistry.java @@ -0,0 +1,15 @@ +package appeng.api; + +/** + * A Registry for locatable items, works based on serial numbers. + */ +public interface ILocateableRegistry { + + /** + * Attempts to find the object with the serial specifed, if it can it returns the object. + * @param ser + * @return requestedObject, or null + */ + public abstract Object findLocateableBySerial(long ser); + +} \ No newline at end of file diff --git a/src/appeng/api/ISpecialComparisonRegistry.java b/src/appeng/api/ISpecialComparisonRegistry.java new file mode 100644 index 00000000..0a30baec --- /dev/null +++ b/src/appeng/api/ISpecialComparisonRegistry.java @@ -0,0 +1,24 @@ +package appeng.api; + +import net.minecraft.item.ItemStack; + +/** + * A Registry of any special comparison handlers for AE To use. + * + */ +public interface ISpecialComparisonRegistry { + + /** + * returns a handler it found for a specific item. + * @param stack + * @return TheHandler or null + */ + IItemComparison getSpecialComparion( ItemStack stack ); + + /** + * Register a new cpecial comparison function with AE. + * @param prov + */ + public void addComparisonProvider( IItemComparisionProvider prov ); + +} diff --git a/src/appeng/api/IWirelessTermHandler.java b/src/appeng/api/IWirelessTermHandler.java new file mode 100644 index 00000000..c38c7ee0 --- /dev/null +++ b/src/appeng/api/IWirelessTermHandler.java @@ -0,0 +1,49 @@ +package appeng.api; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.network.Player; + +/** + * A handler for a wireless terminal. + */ +public interface IWirelessTermHandler { + + /** + * return true, if usePower, hasPower, ect... can be called for the provided item. + * @param is + * @return + */ + boolean canHandle( ItemStack is ); + + /** + * use an amount of power, in AE units + * @param amount is in AE units ( 5 per MJ ), if you return false, the item should be dead and return false for hasPower + * @param is + * @return + */ + boolean usePower( Player player, float amount, ItemStack is ); + + /** + * gets the power status of the item. + * @param is + * @return returns true if there is any power left. + */ + boolean hasPower( Player player, ItemStack is ); + + /** + * Used to get the current key from the item. + * @param player + * @param item + * @return + */ + String getEncryptionKey( ItemStack item ); + + /** + * Encode the wireless frequency via the Controller. + * @param item - the wireless terminal. + * @param encKey - the wireless encryption key. + * @param name - null for now. + */ + void setEncryptionKey( ItemStack item, String encKey, String name ); +} diff --git a/src/appeng/api/IWirelessTermRegistery.java b/src/appeng/api/IWirelessTermRegistery.java new file mode 100644 index 00000000..b9b0a483 --- /dev/null +++ b/src/appeng/api/IWirelessTermRegistery.java @@ -0,0 +1,38 @@ +package appeng.api; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import appeng.api.me.util.IMEInventoryHandler; + +/** + * Registratio record for a Custom Cell handler. + */ +public interface IWirelessTermRegistery { + + /** + * add thsi handler to the list of other wireless handler. + * @param handler + */ + void registerWirelessHandler( IWirelessTermHandler handler ); + + /** + * returns true if theres a handler for this item. + * @param is + * @return + */ + boolean isWirelessTerminal( ItemStack is ); + + /** + * returns a register handler for the item in question, or null if there isn't one. + * @param is + * @return + */ + IWirelessTermHandler getWirelessTerminalHandler( ItemStack is ); + + /** + * opens the wireless terminal gui, the wireless terminal item, must be in the active slot on the tool bar. + */ + void OpenWirelessTermainlGui( ItemStack item, World w, EntityPlayer player ); + +} diff --git a/src/appeng/api/Items.java b/src/appeng/api/Items.java new file mode 100644 index 00000000..0c75f82a --- /dev/null +++ b/src/appeng/api/Items.java @@ -0,0 +1,36 @@ +package appeng.api; + +import net.minecraft.item.ItemStack; + +/** + * Items that have data, actions, or other interesting properties... + * DO NOT USE THESE WITHOUT COPYING THEM : ItemStack.copy() - is your friend. + */ +public class Items +{ + public static ItemStack toolQuartzAxe; + public static ItemStack toolQuartzHoe; + public static ItemStack toolQuartzShovel; + public static ItemStack toolQuartzPick; + public static ItemStack toolQuartzSword; + public static ItemStack toolQuartzWrench; + + public static ItemStack toolEntropyAccelerator; + public static ItemStack toolVibrationCatalyst; + public static ItemStack toolMassCannon; + + public static ItemStack toolQuartzKnife; + + public static ItemStack itemMemoryCard; + + public static ItemStack itemCell1k; + public static ItemStack itemCell4k; + public static ItemStack itemCell16k; + public static ItemStack itemCell64k; + + public static ItemStack itemEncodedAsemblerPattern; + public static ItemStack toolWirelessTerminal; + + @Deprecated + public static ItemStack itemWirelessTerminal; +} diff --git a/src/appeng/api/Materials.java b/src/appeng/api/Materials.java new file mode 100644 index 00000000..c6d8e90c --- /dev/null +++ b/src/appeng/api/Materials.java @@ -0,0 +1,58 @@ +package appeng.api; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/** + * Access to stack-able simple items, these include resources... + * Craftable ingredients, and a few simple items that don't have log of their own... + * DO NOT USE THESE WITHOUT COPYING THEM : ItemStack.copy() - is your friend. + */ +public class Materials +{ + // Tech 1 + public static ItemStack matWoodenGear; + public static ItemStack matIronNugget; + public static ItemStack matCrank; + + // Grinder... + public static ItemStack matQuartzDustNether; + public static ItemStack matQuartzDust; + public static ItemStack matIronDust; + public static ItemStack matGoldDust; + public static ItemStack matFlour; + + // Tech 3 + public static ItemStack matSilicon; + public static ItemStack matProcessorBasicUncooked; + public static ItemStack matProcessorAdvancedUncooked; + public static ItemStack matProcessorBasic; + public static ItemStack matProcessorAdvanced; + + // ME Construction... + public static ItemStack matConversionMatrix; + public static ItemStack matStorageCell; + public static ItemStack matStorageBlock; + public static ItemStack matStorageCluster; + public static ItemStack matWireless; + public static ItemStack matStorageCellHouseing; + public static ItemStack matStorageCellHouseingFuzzy; + public static ItemStack matBlankPattern; + public static ItemStack matStorageSegment; + public static ItemStack matFluxDust; + public static ItemStack matFluxCrystal; + public static ItemStack matFluxPearl; + + // World gen... + public static ItemStack matQuartz; + + // Other items, such as upgrades. + public static ItemStack matWirelessBooster; + public static ItemStack matMatterBall; + public static ItemStack matSingularity; + public static ItemStack matEnderPearlDust; + public static ItemStack matQuantumEntangledSingularity; + + // TEST ITEMS! + public static ItemStack testItem; +} diff --git a/src/appeng/api/README.txt b/src/appeng/api/README.txt new file mode 100644 index 00000000..bcd69c4e --- /dev/null +++ b/src/appeng/api/README.txt @@ -0,0 +1,46 @@ +If your considering using the AE API, please take a moment to read though the following. + +Before we begin, + AE's API will change as new features are added to the mod, I try to keep + the changes to a minimum and try to prevent breaking changes, however it will + probably happen at some point, and it can't truly be avoided in some cases. + +The Grid + AE refers to the "ME Network" internally as "The Grid" you will see methods such + as getGrid(), setGrid() commonly, most interaction with networks, and creating new + network blocks will involve the grid. + +Network Enumeration + If your trying to add a new ME Network Block, you must at minimum implement + IGridTileEntity, and post the GridTileLoadEvent, and GridTileUnloadEvent when your + tile is added / removed respectfully, if you fail to do this correctly, your tile, + may ghost in the network, or cause invalid behaviour. You must inform AE that your + tiles is joining and exiting the Network, with these events or you will not get notified + of any network related features. + +Thread Safety + AE is not thread safe, do not attempt to use the API from other threads, this will + result in crashes, and CME exceptions - and will not end well. + +Blocks / Items / Materials + AE Exposes its Original Item stacks via the Blocks, Items, Materials classes for easy access, + don't change these, if you need to use an item make sure you .copy() it and use the copy, if + failing to do so can result in dupe bugs irregular crafting patterns, and other issues. + +AE and ItemStacks / Item Lists + AE's API commonly refers to IAEItemStacks, and IItemLists this are internally implemented + classes in AE, Do not Implement IAEItemstack, or IItemList, use the util methods to + construct new instances them. + +API Conflicts / Inclusion + Refrain from including portions of the API as class files in your mod, unless required + because your implementing an interface, even then its greatly appreciated if you put in + the effort to get around this. + + If you are not sure how to do this and plan on releasing your mod, I will be happy to explain + what steps you can take to improve compatibility, and prevent conflicts no one likes crashes, + and these cause crashes. + +I've been trying to improve the documentation included in the API java files however things can be +confusing or misleading, if you have questions after trying to figure something out I'm usually +available on IRC. \ No newline at end of file diff --git a/src/appeng/api/TileRef.java b/src/appeng/api/TileRef.java new file mode 100644 index 00000000..db6fe3e6 --- /dev/null +++ b/src/appeng/api/TileRef.java @@ -0,0 +1,60 @@ +package appeng.api; + +import net.minecraft.client.Minecraft; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import appeng.api.events.GridTileUnloadEvent; +import appeng.api.exceptions.AppEngTileMissingException; +import appeng.api.me.tiles.IGridTileEntity; + +public class TileRef extends WorldCoord { + + //private int dimension; + private World w; + boolean wasGrid; + + public TileRef( TileEntity gte ) { + super( gte.xCoord, gte.yCoord, gte.zCoord ); + TileEntity te = gte; + wasGrid = te instanceof IGridTileEntity; + w = te.worldObj; + if ( te.worldObj == null ) + throw new RuntimeException("Tile has no world."); + } + + @SuppressWarnings("unchecked") + public T getTile() throws AppEngTileMissingException + { + // there might be a possible tick where we have TileRefs for unloaded tiles? + if ( w.getChunkProvider().chunkExists(x >> 4, z >> 4) ) + { + TileEntity te = w.getBlockTileEntity( x, y, z ); + if ( te != null ) + { + try + { + T ttt = (T) te; // I have no idea if this causes the exception or not... + return ttt; + } + catch( ClassCastException err ) + { + + } + } + } + + /** + * was this a grid tile? if so inform the grid enum that something has derped. + */ + if ( wasGrid ) + MinecraftForge.EVENT_BUS.post( new GridTileUnloadEvent( null, w, this ) ); + + throw new AppEngTileMissingException( w, x,y,z); + } + + public DimentionalCoord getCoord() { + return new DimentionalCoord( w, x, y, z ); + } + +}; diff --git a/src/appeng/api/Util.java b/src/appeng/api/Util.java new file mode 100644 index 00000000..207d339d --- /dev/null +++ b/src/appeng/api/Util.java @@ -0,0 +1,230 @@ +package appeng.api; + +import java.lang.reflect.InvocationTargetException; + +import cpw.mods.fml.relauncher.ReflectionHelper; +import net.minecraft.item.ItemStack; +import appeng.api.me.util.IAssemblerPattern; +import appeng.api.me.util.IMEInventory; +import appeng.api.me.util.IMEInventoryHandler; +import appeng.api.me.util.IMEInventoryUtil; + +/** + * Returns useful stuff of various sorts to access internal features and stuff, the meat of the important stuff is accessed here... + * + * Available IMCs: + * "AppliedEnergistics", "add-grindable", "itemid,meta,itemid,meta,effort" + * "AppliedEnergistics", "blacklist-cell" "itemid[,meta]" + * "AppliedEnergistics", "blacklist-transitionplane" "itemid[,meta]" + * "AppliedEnergistics", "whitelist-transitionplane" "itemid[,meta]" + * + */ +public class Util +{ + static private IAppEngApi api = null; + + /** + * All future API calls should be made via this method. + * @return + */ + public static IAppEngApi getAppEngApi() + { + try { + Class c = ReflectionHelper.getClass( Util.class.getClassLoader(), "appeng.common.AppEngApi" ); + api = (IAppEngApi) c.getMethod( "getInstance" ).invoke( c ); + } catch ( Throwable e) { + return null; + } + return api; + } + + /** + * returns the wireless terminal registry. + * @return + */ + public static IWirelessTermRegistery getWirelessTermRegistery() + { + if ( api == null ) return null; + return api.getWirelessRegistry(); + } + + /** + * Find an object by its serial. + * @param ser + * @return LocatedObject or null + */ + public static Object getLocateableBySerial( long ser ) + { + if ( api == null ) return null; + return api.getLocateableBySerial( ser ); + } + + /** + * Creates a new AEItemstack. + * @param is + * @return newly generated AE Itemstack + */ + public static IAEItemStack createItemStack( ItemStack is ) + { + if ( api == null ) return null; + return api.createItemStack( is ); + } + + /** + * Simple Wrapper of the insertion process.. + * @param inv + * @param is + * @return ItemsNotInserted or null + */ + public static ItemStack addItemsToInv( IMEInventory inv, ItemStack is ) + { + if ( api == null ) return null; + return api.addItemsToInv( inv, is ); + } + + /** + * Simple Wrapper of the extraction process + * @param inv + * @param is + * @return ItemsExtracted or null + */ + public static ItemStack extractItemsFromInv( IMEInventory inv, ItemStack is ) + { + if ( api == null ) return null; + return api.extractItems( inv, is ); + } + + /** + * Create a new Blank ItemList + * @return new itemlist. + */ + public static IItemList createItemList() + { + if ( api == null ) return null; + return api.createItemList(); + } + + /** + * creates a new IMEInventoryUtil, only useful if you want to use the fancy get items by recipe functionaility. + * @param ime + * @return created InvUtil + */ + public static IMEInventoryUtil getIMEInventoryUtil( IMEInventory ime ) + { + if ( api == null ) return null; + return api.getIMEInventoryUtil( ime ); + } + + /** + * Gets the instance of the special comparison registry ( Bees / Trees ) that sort of stuff + * @return specialComparisonRegistry + */ + public static ISpecialComparisonRegistry getSpecialComparisonRegistry() + { + if ( api == null ) return null; + return api.getSpecialComparsonRegistry(); + } + + /** + * Gets the instance of the external storage registry - Storage Bus + * @return externStorgeRegitry + */ + public static IExternalStorageRegistry getExternalStorageRegistry() + { + if ( api == null ) return null; + return api.getExternalStorageRegistry(); + } + + /** + * Gets the instance of the Cell Registry + * @return returns the cell registry + */ + public static ICellRegistry getCellRegistry() + { + if ( api == null ) return null; + return api.getCellRegistry(); + } + + /** + * Gets instance for the grinder recipe manager. + * @return the grinder manager instance. + */ + public static IGrinderRecipeManager getGrinderRecipeManage() + { + if ( api == null ) return null; + return api.getGrinderRecipeManage(); + } + + /** Is it a Blank Pattern? */ + public static Boolean isBlankPattern(ItemStack i) + { + if ( api == null ) return null; + return api.isBlankPattern( i ); + } + + /** Is it an IAssemblerPattern? */ + public static Boolean isAssemblerPattern(ItemStack i) + { + if ( api == null ) return null; + return api.isAssemblerPattern( i ); + } + + /** Gets the IAssemblerPattern of the Assembly Pattern. */ + public static IAssemblerPattern getAssemblerPattern(ItemStack i) + { + if ( api == null ) return null; + return api.getAssemblerPattern( i ); + } + + /** Is it a IStorageCell, this will only return true for IStoreCells and not custom cells, you should probobly not use it unless you have a specific case. */ + public static Boolean isBasicCell(ItemStack i) + { + if ( api == null ) return null; + return api.isBasicCell( i ); + } + + /** + * if the item is a ME Compatible Storage Cell of any type. + * @param i + * @return true, if it is a storage call. + */ + public static Boolean isCell(ItemStack i) + { + if ( api == null ) return null; + return getCellRegistry().isCellHandled( i ); + } + + /** + * Gets the Interface to insert/extract from the Storage Cell for the item. + * @param i + * @return newly procured cell handler. + */ + public static IMEInventoryHandler getCell(ItemStack i) + { + if ( api == null ) return null; + return getCellRegistry().getHandlerForCell( i ); + } + + /** + * Lets you access internal storage of IStorageCell's + * @param i + * @return only works with Basic Cells, not custom ones, suggested not to use. + */ + public static IMEInventory getBasicCell(ItemStack i) + { + if ( api == null ) return null; + return api.getBasicCell( i ); + } + + /** + * Lets you blast list a specific item from being stored in basic cells, this works on any mod cells that use IStorageCell as well. + * @param ItemID + * @param Meta + */ + public static void addBasicBlackList( int ItemID, int Meta ) + { + if ( api == null ) return; + api.addBasicBlackList( ItemID, Meta ); + } + +} diff --git a/src/appeng/api/WorldCoord.java b/src/appeng/api/WorldCoord.java new file mode 100644 index 00000000..4e525647 --- /dev/null +++ b/src/appeng/api/WorldCoord.java @@ -0,0 +1,132 @@ +package appeng.api; + +import net.minecraftforge.common.ForgeDirection; + +/** + * This is used internally to return a location, in a few places, just use as is... + */ +public class WorldCoord +{ + public int x; + public int y; + public int z; + + public WorldCoord add(ForgeDirection direction, int length) + { + x += direction.offsetX * length; + y += direction.offsetY * length; + z += direction.offsetZ * length; + return this; + } + + public WorldCoord subtract(ForgeDirection direction, int length) + { + x -= direction.offsetX * length; + y -= direction.offsetY * length; + z -= direction.offsetZ * length; + return this; + } + + public WorldCoord add(int _x, int _y, int _z) + { + x += _x; + y += _y; + z += _z; + return this; + } + + public WorldCoord subtract(int _x, int _y, int _z) + { + x -= _x; + y -= _y; + z -= _z; + return this; + } + + public WorldCoord multiple(int _x, int _y, int _z) + { + x *= _x; + y *= _y; + z *= _z; + return this; + } + + public WorldCoord divide(int _x, int _y, int _z) + { + x /= _x; + y /= _y; + z /= _z; + return this; + } + + public WorldCoord(int _x, int _y, int _z) + { + x = _x; + y = _y; + z = _z; + } + + /** + * Will Return NULL if it's at some diagonal! + */ + public ForgeDirection DirectionTo(WorldCoord loc) + { + int ox = x - loc.x; + int oy = y - loc.y; + int oz = z - loc.z; + + int xlen = Math.abs( ox ); + int ylen = Math.abs( oy ); + int zlen = Math.abs( oz ); + + if ( loc.isEqual( this.copy().add( ForgeDirection.EAST, xlen ) ) ) + return ForgeDirection.EAST; + + if ( loc.isEqual( this.copy().add( ForgeDirection.WEST, xlen ) ) ) + return ForgeDirection.WEST; + + if ( loc.isEqual( this.copy().add( ForgeDirection.NORTH, zlen ) ) ) + return ForgeDirection.NORTH; + + if ( loc.isEqual( this.copy().add( ForgeDirection.SOUTH, zlen ) ) ) + return ForgeDirection.SOUTH; + + if ( loc.isEqual( this.copy().add( ForgeDirection.UP, ylen ) ) ) + return ForgeDirection.UP; + + if ( loc.isEqual( this.copy().add( ForgeDirection.DOWN, ylen ) ) ) + return ForgeDirection.DOWN; + + return null; + } + + public boolean isEqual( WorldCoord c ) + { + return x == c.x && y == c.y && z == c.z; + } + + public WorldCoord copy() + { + return new WorldCoord( x, y, z ); + } + + @Override + public boolean equals(Object obj) + { + if ( obj instanceof WorldCoord ) + return isEqual( (WorldCoord)obj ); + return false; + } + + @Override + public String toString() + { + return "" + x + "," + y + "," + z; + } + + @Override + public int hashCode() + { + return (y << 24) ^ x ^ z; + } +} diff --git a/src/appeng/api/config/ActionItems.java b/src/appeng/api/config/ActionItems.java new file mode 100644 index 00000000..ff4559de --- /dev/null +++ b/src/appeng/api/config/ActionItems.java @@ -0,0 +1,17 @@ +package appeng.api.config; + + +public enum ActionItems implements IConfigEnum { + Wrench, + Close; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "FuzzyMode"; + } +} \ No newline at end of file diff --git a/src/appeng/api/config/CondenserOuput.java b/src/appeng/api/config/CondenserOuput.java new file mode 100644 index 00000000..2c187dae --- /dev/null +++ b/src/appeng/api/config/CondenserOuput.java @@ -0,0 +1,19 @@ +package appeng.api.config; + + +public enum CondenserOuput implements IConfigEnum { + Trash, + MatterBalls, + Singularity; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "CondenserOutput"; + } + +} \ No newline at end of file diff --git a/src/appeng/api/config/EnableDisable.java b/src/appeng/api/config/EnableDisable.java new file mode 100644 index 00000000..20c195bb --- /dev/null +++ b/src/appeng/api/config/EnableDisable.java @@ -0,0 +1,18 @@ +package appeng.api.config; + + +public enum EnableDisable implements IConfigEnum { + Enabled, + Disabled; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "CondenserOutput"; + } + +} \ No newline at end of file diff --git a/src/appeng/api/config/FullnessMode.java b/src/appeng/api/config/FullnessMode.java new file mode 100644 index 00000000..a3f79f4b --- /dev/null +++ b/src/appeng/api/config/FullnessMode.java @@ -0,0 +1,19 @@ +package appeng.api.config; + + +// do not change names.. +public enum FullnessMode implements IConfigEnum { + Empty, + Half, + Full; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "FullnessMode"; + } +} \ No newline at end of file diff --git a/src/appeng/api/config/FuzzyMode.java b/src/appeng/api/config/FuzzyMode.java new file mode 100644 index 00000000..40d57127 --- /dev/null +++ b/src/appeng/api/config/FuzzyMode.java @@ -0,0 +1,27 @@ +package appeng.api.config; + + +public enum FuzzyMode implements IConfigEnum { + IgnoreAll(-1.0F), + Percent_99(1.0F), + Percent_75(0.75F), + Percent_50(0.5F), + Percent_25(0.25F); + + public float breakPoint; + + private FuzzyMode( float p ) + { + breakPoint = p; + } + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "FuzzyMode"; + } +} \ No newline at end of file diff --git a/src/appeng/api/config/IConfigEnum.java b/src/appeng/api/config/IConfigEnum.java new file mode 100644 index 00000000..18bafec7 --- /dev/null +++ b/src/appeng/api/config/IConfigEnum.java @@ -0,0 +1,11 @@ +package appeng.api.config; + +public interface IConfigEnum { + + IConfigEnum[] getValues(); + + int ordinal(); + + String getName(); + +} diff --git a/src/appeng/api/config/InterfaceBlockingMode.java b/src/appeng/api/config/InterfaceBlockingMode.java new file mode 100644 index 00000000..08978d20 --- /dev/null +++ b/src/appeng/api/config/InterfaceBlockingMode.java @@ -0,0 +1,17 @@ +package appeng.api.config; + +public enum InterfaceBlockingMode implements IConfigEnum { + NonBlocking, + Blocking; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "InterfaceBlockingMode"; + } + +} \ No newline at end of file diff --git a/src/appeng/api/config/InterfaceCraftingMode.java b/src/appeng/api/config/InterfaceCraftingMode.java new file mode 100644 index 00000000..ce783b42 --- /dev/null +++ b/src/appeng/api/config/InterfaceCraftingMode.java @@ -0,0 +1,17 @@ +package appeng.api.config; + +public enum InterfaceCraftingMode implements IConfigEnum { + Craft, + DontCraft; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "InterfaceCraftingMode"; + } + +} diff --git a/src/appeng/api/config/ItemFlow.java b/src/appeng/api/config/ItemFlow.java new file mode 100644 index 00000000..b7d60cd6 --- /dev/null +++ b/src/appeng/api/config/ItemFlow.java @@ -0,0 +1,18 @@ +package appeng.api.config; + + +public enum ItemFlow implements IConfigEnum { + + READ, WRITE, READ_WRITE; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "ItemFlow"; + } + +} \ No newline at end of file diff --git a/src/appeng/api/config/ListMode.java b/src/appeng/api/config/ListMode.java new file mode 100644 index 00000000..71bf9377 --- /dev/null +++ b/src/appeng/api/config/ListMode.java @@ -0,0 +1,18 @@ +package appeng.api.config; + + +public enum ListMode implements IConfigEnum { + + WHITELIST, BLACKLIST; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "ListMode"; + } + +} \ No newline at end of file diff --git a/src/appeng/api/config/MatchingMode.java b/src/appeng/api/config/MatchingMode.java new file mode 100644 index 00000000..8ce433a8 --- /dev/null +++ b/src/appeng/api/config/MatchingMode.java @@ -0,0 +1,17 @@ +package appeng.api.config; + + +public enum MatchingMode implements IConfigEnum { + Fuzzy, + Precision; + + @Override + public IConfigEnum[] getValues() { + return MatchingMode.values(); + } + + @Override + public String getName() { + return "MatchingMode"; + } +} \ No newline at end of file diff --git a/src/appeng/api/config/OperationMode.java b/src/appeng/api/config/OperationMode.java new file mode 100644 index 00000000..6a3f94e1 --- /dev/null +++ b/src/appeng/api/config/OperationMode.java @@ -0,0 +1,18 @@ +package appeng.api.config; + + +// do not change names.. +public enum OperationMode implements IConfigEnum { + Fill, + Empty; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "OperationMode"; + } +} \ No newline at end of file diff --git a/src/appeng/api/config/PowerUnits.java b/src/appeng/api/config/PowerUnits.java new file mode 100644 index 00000000..7917050a --- /dev/null +++ b/src/appeng/api/config/PowerUnits.java @@ -0,0 +1,19 @@ +package appeng.api.config; + + +public enum PowerUnits implements IConfigEnum { + AE, + MJ, + EU, + UE; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "PowerUnits"; + } +} \ No newline at end of file diff --git a/src/appeng/api/config/RedstoneModeInput.java b/src/appeng/api/config/RedstoneModeInput.java new file mode 100644 index 00000000..edbc51f9 --- /dev/null +++ b/src/appeng/api/config/RedstoneModeInput.java @@ -0,0 +1,20 @@ +package appeng.api.config; + + +// do not change names.. +public enum RedstoneModeInput implements IConfigEnum { + Ignore, + WhenOff, + WhenOn, + OnPulse; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "RedstoneMode"; + } +} \ No newline at end of file diff --git a/src/appeng/api/config/RedstoneModeInputOnOff.java b/src/appeng/api/config/RedstoneModeInputOnOff.java new file mode 100644 index 00000000..e01cad66 --- /dev/null +++ b/src/appeng/api/config/RedstoneModeInputOnOff.java @@ -0,0 +1,19 @@ +package appeng.api.config; + + +// do not change names.. +public enum RedstoneModeInputOnOff implements IConfigEnum { + Ignore, + WhenOff, + WhenOn; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "RedstoneMode"; + } +} \ No newline at end of file diff --git a/src/appeng/api/config/RedstoneModeOutput.java b/src/appeng/api/config/RedstoneModeOutput.java new file mode 100644 index 00000000..b94b116f --- /dev/null +++ b/src/appeng/api/config/RedstoneModeOutput.java @@ -0,0 +1,18 @@ +package appeng.api.config; + + +// do not change names.. +public enum RedstoneModeOutput implements IConfigEnum { + WhenOff, + WhenOn; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "RedstoneMode"; + } +} \ No newline at end of file diff --git a/src/appeng/api/config/SearchBoxMode.java b/src/appeng/api/config/SearchBoxMode.java new file mode 100644 index 00000000..7a99d1ed --- /dev/null +++ b/src/appeng/api/config/SearchBoxMode.java @@ -0,0 +1,22 @@ +package appeng.api.config; + +import net.minecraft.src.ModLoader; + +public enum SearchBoxMode implements IConfigEnum { + Autosearch, + Standard, + NEIAutoSearch, + NEIStandard; + + @Override + public IConfigEnum[] getValues() { + if ( ModLoader.isModLoaded( "NotEnoughItems" ) ) + return values(); + return new SearchBoxMode[]{ Autosearch, Standard }; + } + + @Override + public String getName() { + return "SearchBoxMode"; + } +} \ No newline at end of file diff --git a/src/appeng/api/config/SortDir.java b/src/appeng/api/config/SortDir.java new file mode 100644 index 00000000..d09904e5 --- /dev/null +++ b/src/appeng/api/config/SortDir.java @@ -0,0 +1,18 @@ +package appeng.api.config; + + +public enum SortDir implements IConfigEnum +{ + ASC, + DESC; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "SortDir"; + } +} \ No newline at end of file diff --git a/src/appeng/api/config/SortOrder.java b/src/appeng/api/config/SortOrder.java new file mode 100644 index 00000000..fc18c4a4 --- /dev/null +++ b/src/appeng/api/config/SortOrder.java @@ -0,0 +1,20 @@ +package appeng.api.config; + + +public enum SortOrder implements IConfigEnum +{ + Name, + Size, + Priority, + ItemID; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "SortOrder"; + } +} \ No newline at end of file diff --git a/src/appeng/api/config/StackModeInput.java b/src/appeng/api/config/StackModeInput.java new file mode 100644 index 00000000..d99dda19 --- /dev/null +++ b/src/appeng/api/config/StackModeInput.java @@ -0,0 +1,18 @@ +package appeng.api.config; + + +// do not change names.. +public enum StackModeInput implements IConfigEnum { + Single, + Stack; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "StackMode"; + } +} \ No newline at end of file diff --git a/src/appeng/api/config/StackModeOutput.java b/src/appeng/api/config/StackModeOutput.java new file mode 100644 index 00000000..546b283a --- /dev/null +++ b/src/appeng/api/config/StackModeOutput.java @@ -0,0 +1,20 @@ +package appeng.api.config; + + +// do not change names.. +public enum StackModeOutput implements IConfigEnum { + Single, + Stack, + Craft, + CraftOnly; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "StackMode"; + } +} \ No newline at end of file diff --git a/src/appeng/api/config/TransferDir.java b/src/appeng/api/config/TransferDir.java new file mode 100644 index 00000000..ed8cd4e1 --- /dev/null +++ b/src/appeng/api/config/TransferDir.java @@ -0,0 +1,18 @@ +package appeng.api.config; + + +public enum TransferDir implements IConfigEnum +{ + LEFT, + RIGHT; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "TransferDir"; + } +} \ No newline at end of file diff --git a/src/appeng/api/config/ViewItems.java b/src/appeng/api/config/ViewItems.java new file mode 100644 index 00000000..ec5c2d0f --- /dev/null +++ b/src/appeng/api/config/ViewItems.java @@ -0,0 +1,19 @@ +package appeng.api.config; + + +public enum ViewItems implements IConfigEnum +{ + ALL, + STORED, + CRAFTABLE; + + @Override + public IConfigEnum[] getValues() { + return values(); + } + + @Override + public String getName() { + return "ViewItems"; + } +} \ No newline at end of file diff --git a/src/appeng/api/events/AEWorldEvent.java b/src/appeng/api/events/AEWorldEvent.java new file mode 100644 index 00000000..d4cb74b0 --- /dev/null +++ b/src/appeng/api/events/AEWorldEvent.java @@ -0,0 +1,17 @@ +package appeng.api.events; + +import net.minecraft.world.World; +import net.minecraftforge.event.Event; + +/** + * Simple Alternative to WorldEvent, thanks to a certain mod that wants to crash on WorldEvents + */ +public class AEWorldEvent extends Event +{ + final public World world; + + public AEWorldEvent( World w ) + { + world = w; + } +} diff --git a/src/appeng/api/events/GridErrorEvent.java b/src/appeng/api/events/GridErrorEvent.java new file mode 100644 index 00000000..748f1a6e --- /dev/null +++ b/src/appeng/api/events/GridErrorEvent.java @@ -0,0 +1,18 @@ +package appeng.api.events; + +import net.minecraft.world.World; +import net.minecraftforge.event.world.WorldEvent; +import appeng.api.WorldCoord; + +/** + * an error, basically just causes an update, use it if there is really an error, other wise just ignore it. + */ +public class GridErrorEvent extends AEWorldEvent { + + public WorldCoord coord; + public GridErrorEvent(World world, WorldCoord wc ) { + super(world); + coord = wc; + } + +} diff --git a/src/appeng/api/events/GridPatternUpdateEvent.java b/src/appeng/api/events/GridPatternUpdateEvent.java new file mode 100644 index 00000000..413b13e9 --- /dev/null +++ b/src/appeng/api/events/GridPatternUpdateEvent.java @@ -0,0 +1,22 @@ +package appeng.api.events; + +import net.minecraft.world.World; +import net.minecraftforge.event.world.WorldEvent; +import appeng.api.WorldCoord; +import appeng.api.me.util.IGridInterface; + +/** + * Posted when crafting options in a AE Network update, you can watch for them if you want to. + */ +public class GridPatternUpdateEvent extends AEWorldEvent { + + final public WorldCoord coord; + final public IGridInterface grid; + + public GridPatternUpdateEvent(World world, WorldCoord wc, IGridInterface gi ) { + super(world); + grid = gi; + coord = wc; + } + +} diff --git a/src/appeng/api/events/GridStorageUpdateEvent.java b/src/appeng/api/events/GridStorageUpdateEvent.java new file mode 100644 index 00000000..aab73c42 --- /dev/null +++ b/src/appeng/api/events/GridStorageUpdateEvent.java @@ -0,0 +1,22 @@ +package appeng.api.events; + +import net.minecraft.world.World; +import net.minecraftforge.event.world.WorldEvent; +import appeng.api.WorldCoord; +import appeng.api.me.util.IGridInterface; + +/** + * Posted when storage options in a AE Network update, such as a new Storage Bus or Cell is added, or removed. + */ +public class GridStorageUpdateEvent extends AEWorldEvent { + + final public WorldCoord coord; + final public IGridInterface grid; + + public GridStorageUpdateEvent(World world, WorldCoord wc, IGridInterface gi ) { + super(world); + grid = gi; + coord = wc; + } + +} diff --git a/src/appeng/api/events/GridTileConnectivityEvent.java b/src/appeng/api/events/GridTileConnectivityEvent.java new file mode 100644 index 00000000..9d793899 --- /dev/null +++ b/src/appeng/api/events/GridTileConnectivityEvent.java @@ -0,0 +1,22 @@ +package appeng.api.events; + +import net.minecraft.world.World; +import net.minecraftforge.event.world.WorldEvent; +import appeng.api.WorldCoord; +import appeng.api.me.tiles.IGridTileEntity; + +/** + * The network has changed, and must be updated. + */ +public class GridTileConnectivityEvent extends AEWorldEvent { + + public WorldCoord coord; + public IGridTileEntity te; + + public GridTileConnectivityEvent( IGridTileEntity _te, World world, WorldCoord wc ) { + super(world); + te = _te; + coord = wc; + } + +} diff --git a/src/appeng/api/events/GridTileLoadEvent.java b/src/appeng/api/events/GridTileLoadEvent.java new file mode 100644 index 00000000..2293f56a --- /dev/null +++ b/src/appeng/api/events/GridTileLoadEvent.java @@ -0,0 +1,22 @@ +package appeng.api.events; + +import net.minecraft.world.World; +import net.minecraftforge.event.world.WorldEvent; +import appeng.api.WorldCoord; +import appeng.api.me.tiles.IGridTileEntity; + +/** + * A Tile has been added to the world, and should be evaluated for Network Connectivity. + */ +public class GridTileLoadEvent extends AEWorldEvent { + + public WorldCoord coord; + public IGridTileEntity te; + + public GridTileLoadEvent(IGridTileEntity _te, World world, WorldCoord wc ) { + super(world); + te = _te; + coord = wc; + } + +} diff --git a/src/appeng/api/events/GridTileUnloadEvent.java b/src/appeng/api/events/GridTileUnloadEvent.java new file mode 100644 index 00000000..d96ccefb --- /dev/null +++ b/src/appeng/api/events/GridTileUnloadEvent.java @@ -0,0 +1,22 @@ +package appeng.api.events; + +import net.minecraft.world.World; +import net.minecraftforge.event.world.WorldEvent; +import appeng.api.WorldCoord; +import appeng.api.me.tiles.IGridTileEntity; + +/** + * A Tile has been removed from the world, and should no longer be considered for connectivity. + */ +public class GridTileUnloadEvent extends AEWorldEvent { + + public WorldCoord coord; + public IGridTileEntity te; + + public GridTileUnloadEvent(IGridTileEntity _te,World world, WorldCoord wc ) { + super(world); + te = _te; + coord = wc; + } + +} diff --git a/src/appeng/api/events/LocateableEventAnnounce.java b/src/appeng/api/events/LocateableEventAnnounce.java new file mode 100644 index 00000000..2605629e --- /dev/null +++ b/src/appeng/api/events/LocateableEventAnnounce.java @@ -0,0 +1,25 @@ +package appeng.api.events; + +import net.minecraftforge.event.Event; +import appeng.api.me.tiles.ILocateable; + +/** + * Used to Notify the Location Registry of objects, and their availability. + */ +public class LocateableEventAnnounce extends Event { + + public enum LocateableEvent { + Register, // Adds the locateable to the registry + Unregister // Removes the Locatable from the registry + }; + + final public ILocateable target; + final public LocateableEvent change; + + public LocateableEventAnnounce( ILocateable o, LocateableEvent ev ) + { + target = o; + change = ev; + } + +} diff --git a/src/appeng/api/events/MultiBlockUpdateEvent.java b/src/appeng/api/events/MultiBlockUpdateEvent.java new file mode 100644 index 00000000..280abddd --- /dev/null +++ b/src/appeng/api/events/MultiBlockUpdateEvent.java @@ -0,0 +1,22 @@ +package appeng.api.events; + +import net.minecraft.world.World; +import net.minecraftforge.event.world.WorldEvent; +import appeng.api.WorldCoord; +import appeng.api.me.tiles.IGridTileEntity; + +/** + * Used by the MAC to trigger updates in its structure. + */ +public class MultiBlockUpdateEvent extends AEWorldEvent { + + public WorldCoord coord; + public IGridTileEntity te; + + public MultiBlockUpdateEvent( IGridTileEntity _te, World world, WorldCoord wc ) { + super(world); + coord = wc; + te = _te; + } + +} diff --git a/src/appeng/api/exceptions/AppEngException.java b/src/appeng/api/exceptions/AppEngException.java new file mode 100644 index 00000000..940e7bee --- /dev/null +++ b/src/appeng/api/exceptions/AppEngException.java @@ -0,0 +1,12 @@ +package appeng.api.exceptions; + +public class AppEngException extends Exception +{ + + private static final long serialVersionUID = -9051434206368465494L; + + public AppEngException(String t) + { + super(t); + } +} diff --git a/src/appeng/api/exceptions/AppEngTileMissingException.java b/src/appeng/api/exceptions/AppEngTileMissingException.java new file mode 100644 index 00000000..067e47f1 --- /dev/null +++ b/src/appeng/api/exceptions/AppEngTileMissingException.java @@ -0,0 +1,30 @@ +package appeng.api.exceptions; + +import cpw.mods.fml.common.FMLLog; +import net.minecraft.world.World; +import appeng.api.DimentionalCoord; + +public class AppEngTileMissingException extends Exception { + + private static final long serialVersionUID = -3502227742711078681L; + public DimentionalCoord dc; + + @Override + public void printStackTrace() { + try + { + FMLLog.info( "[AppEng] Missing Tile at "+dc.x+", "+dc.y+", "+dc.z+" in +"+dc.getWorld().getWorldInfo().getVanillaDimension() ); + } + catch( Throwable _ ) + { + FMLLog.info( "[AppEng] Missing Tile at "+dc.x+", "+dc.y+", "+dc.z ); + } + super.printStackTrace(); + } + + public AppEngTileMissingException(World w, int x, int y, int z) + { + dc = new DimentionalCoord( w, x, y, z ); + } + +} diff --git a/src/appeng/api/integration/IBeeComparison.java b/src/appeng/api/integration/IBeeComparison.java new file mode 100644 index 00000000..8e4082e1 --- /dev/null +++ b/src/appeng/api/integration/IBeeComparison.java @@ -0,0 +1,20 @@ +package appeng.api.integration; + +import forestry.api.genetics.IIndividual; + +/** + * A interface to get access to the individual settings for AE's Internal Bee Comparison handler. + * + * Assessable via: ( IBeeComparison ) IAEItemStack.getTagCompound().getSpecialComparison() + * + * If you don't have the forestry api, just delete this file when using the API. + */ +public interface IBeeComparison { + + /** + * returns the Forestry IIndividual for this comparison object + * @return + */ + IIndividual getIndividual(); + +} diff --git a/src/appeng/api/me/items/IAEChargeableItem.java b/src/appeng/api/me/items/IAEChargeableItem.java new file mode 100644 index 00000000..8619a8b7 --- /dev/null +++ b/src/appeng/api/me/items/IAEChargeableItem.java @@ -0,0 +1,25 @@ + +package appeng.api.me.items; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/* + * A simple AE interface used internally for PowerRelay charging. + */ +public interface IAEChargeableItem { + + /* + * Return the amount of energy not used. + * + * if you return the same amount out, as was passed in, then it will consider charging done. + * + */ + public float addEnergy( ItemStack target, float energy ); + + /* + * Must return true for the target item for it to be considered a charageable item. + */ + public boolean isChargeable( ItemStack it ); + +} diff --git a/src/appeng/api/me/items/IAEWrench.java b/src/appeng/api/me/items/IAEWrench.java new file mode 100644 index 00000000..6abead7b --- /dev/null +++ b/src/appeng/api/me/items/IAEWrench.java @@ -0,0 +1,9 @@ +package appeng.api.me.items; + +import net.minecraft.entity.player.EntityPlayer; + +public interface IAEWrench { + + boolean canWrench(EntityPlayer player, int x, int y, int z); + +} diff --git a/src/appeng/api/me/items/IAssemblerPatternItem.java b/src/appeng/api/me/items/IAssemblerPatternItem.java new file mode 100644 index 00000000..42532da9 --- /dev/null +++ b/src/appeng/api/me/items/IAssemblerPatternItem.java @@ -0,0 +1,8 @@ +package appeng.api.me.items; + +/** + * Like ILocationPatternItem, not really useful... + */ +public interface IAssemblerPatternItem +{ +} diff --git a/src/appeng/api/me/items/ILocationPatternItem.java b/src/appeng/api/me/items/ILocationPatternItem.java new file mode 100644 index 00000000..58a0bd4a --- /dev/null +++ b/src/appeng/api/me/items/ILocationPatternItem.java @@ -0,0 +1,7 @@ +package appeng.api.me.items; + +/** + * Like IAssemblerPatternItem, not really useful... + */ +public interface ILocationPatternItem { +} diff --git a/src/appeng/api/me/items/IMEPatternItem.java b/src/appeng/api/me/items/IMEPatternItem.java new file mode 100644 index 00000000..d9458709 --- /dev/null +++ b/src/appeng/api/me/items/IMEPatternItem.java @@ -0,0 +1,9 @@ +package appeng.api.me.items; + +/** + * Some basic actions you can perform on Patterns. + */ +public interface IMEPatternItem { + boolean isEncoded(); + String Type(); +} diff --git a/src/appeng/api/me/items/IMemoryCard.java b/src/appeng/api/me/items/IMemoryCard.java new file mode 100644 index 00000000..f9c1df53 --- /dev/null +++ b/src/appeng/api/me/items/IMemoryCard.java @@ -0,0 +1,40 @@ +package appeng.api.me.items; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +/** + * used to interact with memory card items. + */ +public interface IMemoryCard { + + /** + * returns true if the item is in fact a memory card. + * @param is + * @return + */ + boolean isMemoryCard( ItemStack is ); + + /** + * Configures the data stored on the memory card, the SettingsName, will be localized when displayed. + * @param is + * @param SettingsName + * @param data + */ + void setMemoryCardContents( ItemStack is, String SettingsName, NBTTagCompound data ); + + /** + * returns the settings name provided previously by setMemoryCardContents, or "AppEng.GuiITooltip.Blank" if there is no settings. + * @param is + * @return + */ + String getSettingsName( ItemStack is ); + + /** + * returns the NBT Data previously saved by setMemoryCardContents, or an empty NBTCompound + * @param is + * @return + */ + NBTTagCompound getData( ItemStack is ); + +} diff --git a/src/appeng/api/me/items/IStorageCell.java b/src/appeng/api/me/items/IStorageCell.java new file mode 100644 index 00000000..d77580d8 --- /dev/null +++ b/src/appeng/api/me/items/IStorageCell.java @@ -0,0 +1,48 @@ +package appeng.api.me.items; + +import appeng.api.IAEItemStack; +import net.minecraft.item.ItemStack; + +/** + * Any item which implements this can be treated as an IMEInventory via Util.getCell / Util.isCell + * It automatically handles the internals and NBT data, which is both nice, and bad for you! + */ +public interface IStorageCell +{ + /** + * rv0 - If this returns something where N % 8 != 0 Then you will be shot on sight, or your car will explode, something like that least... + * @param cellItem + * @return numberofBytes + */ + int getBytes( ItemStack cellItem ); + + /** + * rv0 - Determines the number of bytes used for any type included on the cell. + * @param cellItem + * @return numberOfBytes + */ + int BytePerType( ItemStack iscellItem ); + + /** + * rv11 - Must be between 1 and 63, indicates how many types you want to store on the item. + * @param cellItem + * @return numberOfTypes + */ + int getTotalTypes( ItemStack cellItem ); + + /** + * rv11 - allows you to fine tune which items are allowed on a given cell, + * if you don't care, just return false; + * As the handler for this type of cell is still the default cells, the normal AE black list is also applied. + * @param cellItem + * @param requsetedAddition + * @return preventAdditionOfItem + */ + boolean isBlackListed( ItemStack cellItem, IAEItemStack requsetedAddition ); + + /** + * rv11 - allows you to specify if this storage cell can be stored inside other storage cells, only set this for special items like the matter cannon that are not general purpose storage. + * @return + */ + boolean storableInStorageCell(); +} diff --git a/src/appeng/api/me/items/IStorageComponent.java b/src/appeng/api/me/items/IStorageComponent.java new file mode 100644 index 00000000..f905373f --- /dev/null +++ b/src/appeng/api/me/items/IStorageComponent.java @@ -0,0 +1,21 @@ +package appeng.api.me.items; + +import net.minecraft.item.ItemStack; + +public interface IStorageComponent { + + /** + * rv11 - This isn't necessarily the same as if you make a storage cell out of it, but all of AE's default cells do it that way, its currently only used for the condenser. + * @param cellItem + * @return numberofBytes + */ + int getBytes( ItemStack is ); + + /** + * rv11 - just true or false for the item stack. + * @param is + * @return + */ + boolean isStorageComponent( ItemStack is ); + +} diff --git a/src/appeng/api/me/tiles/IAssemblerMB.java b/src/appeng/api/me/tiles/IAssemblerMB.java new file mode 100644 index 00000000..9b7cf72a --- /dev/null +++ b/src/appeng/api/me/tiles/IAssemblerMB.java @@ -0,0 +1,20 @@ +package appeng.api.me.tiles; + +import appeng.api.WorldCoord; +import appeng.api.me.util.IAssemblerCluster; + +public interface IAssemblerMB { + + /** + * Do this: + * return new WorldCoord( TileEntity.xCoord, TileEntity.yCoord, TileEntity.zCoord ); + */ + public WorldCoord getLocation(); + public IAssemblerCluster getCluster(); + public void updateStatus( IAssemblerCluster ac ); + public boolean isComplete(); + + void calculateMultiblock( long instanceCalc ); + public long markViewed(long inst); + +} diff --git a/src/appeng/api/me/tiles/IAssemblerPatternProvider.java b/src/appeng/api/me/tiles/IAssemblerPatternProvider.java new file mode 100644 index 00000000..b59f0b23 --- /dev/null +++ b/src/appeng/api/me/tiles/IAssemblerPatternProvider.java @@ -0,0 +1,11 @@ +package appeng.api.me.tiles; + +import appeng.api.me.util.IAssemblerPattern; + +/** + * Both useless and incredibly useful, maybe... + */ +public interface IAssemblerPatternProvider +{ + public IAssemblerPattern provideAssemblerPattern(); +} diff --git a/src/appeng/api/me/tiles/ICellContainer.java b/src/appeng/api/me/tiles/ICellContainer.java new file mode 100644 index 00000000..40481a5e --- /dev/null +++ b/src/appeng/api/me/tiles/ICellContainer.java @@ -0,0 +1,24 @@ +package appeng.api.me.tiles; + +import java.util.List; + +import appeng.api.me.util.IMEInventoryHandler; + +/** + * Represents a tile that contributes to storage, such as a ME Chest, or ME Drive. + * + * Remember to trigger the appropriate storage update vents, when your getCellArray Changes. * + */ +public interface ICellContainer { + + /** + * Inventory of the tile for use with ME, should always return an valid list, never NULL. + */ + List getCellArray(); + + /** + * the storage's priority. + */ + int getPriority(); + +} diff --git a/src/appeng/api/me/tiles/ICellProvider.java b/src/appeng/api/me/tiles/ICellProvider.java new file mode 100644 index 00000000..e65d09ad --- /dev/null +++ b/src/appeng/api/me/tiles/ICellProvider.java @@ -0,0 +1,23 @@ +package appeng.api.me.tiles; + +import appeng.api.me.util.IMEInventoryHandler; + +/** + * Both useless and incredibly useful, maybe... + */ +public interface ICellProvider +{ + /** + * consume power to add an item to the storage system. + * @param items + * @param multiplier + * @return + */ + public int usePowerForAddition( int items, int multiplier ); + + /** + * returns a ME Inventory for interaction. + */ + public IMEInventoryHandler provideCell(); + +} diff --git a/src/appeng/api/me/tiles/IColoredMETile.java b/src/appeng/api/me/tiles/IColoredMETile.java new file mode 100644 index 00000000..70a61cf9 --- /dev/null +++ b/src/appeng/api/me/tiles/IColoredMETile.java @@ -0,0 +1,36 @@ +package appeng.api.me.tiles; + +/** + * Used to signify which color a particular IGridTileEntity or IGridMachine is, you must implement both, if you wish to have color bias. + */ +public interface IColoredMETile +{ + public static String[] Colors = { + "Blue", + "Black", + "White", + "Brown", + "Red", + "Yellow", + "Green" + }; + + /** + * return true, if your block has a color, or false, if it dosn't. + * this allows you to have a colored block that can pretend to be colorless. + * @return true, if colored, false if not. + */ + boolean isColored(); + + /** + * Change the color, AE dosn't call this except for its own blocks, its simply included for completeness. + * @param offset + */ + void setColor( int offset ); + + /** + * which color is this tile? + * @return index into the above ColorsList. + */ + int getColor(); +} diff --git a/src/appeng/api/me/tiles/IConfigureableTile.java b/src/appeng/api/me/tiles/IConfigureableTile.java new file mode 100644 index 00000000..fbaa38de --- /dev/null +++ b/src/appeng/api/me/tiles/IConfigureableTile.java @@ -0,0 +1,28 @@ +package appeng.api.me.tiles; + +import java.util.List; + +/** + * Some ME Tiles can be configured, generally via interface, but these let you do this programatically. + */ +public interface IConfigureableTile { + + /** Switches configuration to next option... ( returns new configuration. ) */ + String prevConfiguration(String name); + + /** Switches configuration to next option... ( returns new configuration. ) */ + String nextConfiguration(String name); + + /** Gets a list off all the configurations... */ + List getConfigurations(); + + /** Gets the options of a particular configuration. */ + List getConfiguationOptions( String name ); + + /** Set a configuration to a specific option... ( returns the old one. ) */ + String setConfiguration(String name, String value); + + /** The the current value for a configuration. */ + String getConfiguration(String name); + +} diff --git a/src/appeng/api/me/tiles/IConnectionSensitive.java b/src/appeng/api/me/tiles/IConnectionSensitive.java new file mode 100644 index 00000000..723401c1 --- /dev/null +++ b/src/appeng/api/me/tiles/IConnectionSensitive.java @@ -0,0 +1,11 @@ +package appeng.api.me.tiles; + +import java.util.Set; + +import net.minecraftforge.common.ForgeDirection; + +public interface IConnectionSensitive { + + void onMEConnectionsChanged( Set connections, Set visualConnections ); + +} diff --git a/src/appeng/api/me/tiles/IDirectionalMETile.java b/src/appeng/api/me/tiles/IDirectionalMETile.java new file mode 100644 index 00000000..1cccdc63 --- /dev/null +++ b/src/appeng/api/me/tiles/IDirectionalMETile.java @@ -0,0 +1,20 @@ +package appeng.api.me.tiles; + +import net.minecraftforge.common.ForgeDirection; + +/** + * Used to signify which directions a particular IGridTileEntity or IGridMachine can connect to/from, + * you must implement both, if you wish to have this functionality. + * + * Example Buses, that do not conenct in the direction of the bus. + */ +public interface IDirectionalMETile +{ + + /** + * return true if this tile can connect in a specific direction. + * @param dir + * @return true, if it can connect. + */ + boolean canConnect( ForgeDirection dir ); +} diff --git a/src/appeng/api/me/tiles/IExtendedCellProvider.java b/src/appeng/api/me/tiles/IExtendedCellProvider.java new file mode 100644 index 00000000..5df4532b --- /dev/null +++ b/src/appeng/api/me/tiles/IExtendedCellProvider.java @@ -0,0 +1,13 @@ +package appeng.api.me.tiles; + +import appeng.api.me.util.IMEInventoryHandler; + +/** + * Both useless and incredibly useful, maybe... + */ +public interface IExtendedCellProvider extends ICellProvider +{ + + public IMEInventoryHandler provideCell( String Filter ); + +} diff --git a/src/appeng/api/me/tiles/IFulllyOptionalMETile.java b/src/appeng/api/me/tiles/IFulllyOptionalMETile.java new file mode 100644 index 00000000..664bd228 --- /dev/null +++ b/src/appeng/api/me/tiles/IFulllyOptionalMETile.java @@ -0,0 +1,11 @@ +package appeng.api.me.tiles; + +/** + * Cables will disconnect if its not enabled, + * this means that they will fail to appear connected, example - MAC + */ +public interface IFulllyOptionalMETile extends IOptionalMETile { + + boolean isSeperated(); + +} diff --git a/src/appeng/api/me/tiles/IGridMachine.java b/src/appeng/api/me/tiles/IGridMachine.java new file mode 100644 index 00000000..c62d3a69 --- /dev/null +++ b/src/appeng/api/me/tiles/IGridMachine.java @@ -0,0 +1,13 @@ +package appeng.api.me.tiles; + +/** + * Allows you to drain energy via ME Cables, if you only care if the grid is powered you only need IGridTileEntity. + */ +public abstract interface IGridMachine extends IGridTileEntity +{ + /** + * how much power this entity drains to run constantly. + */ + public abstract float getPowerDrainPerTick(); + +} diff --git a/src/appeng/api/me/tiles/IGridTeleport.java b/src/appeng/api/me/tiles/IGridTeleport.java new file mode 100644 index 00000000..6703b4e1 --- /dev/null +++ b/src/appeng/api/me/tiles/IGridTeleport.java @@ -0,0 +1,11 @@ +package appeng.api.me.tiles; + +import appeng.api.DimentionalCoord; + +/** + * Create a connection to a normally not connected tile + */ +public interface IGridTeleport +{ + DimentionalCoord[] findRemoteSide(); +} diff --git a/src/appeng/api/me/tiles/IGridTileEntity.java b/src/appeng/api/me/tiles/IGridTileEntity.java new file mode 100644 index 00000000..7b956302 --- /dev/null +++ b/src/appeng/api/me/tiles/IGridTileEntity.java @@ -0,0 +1,49 @@ +package appeng.api.me.tiles; + +import net.minecraft.world.World; +import appeng.api.WorldCoord; +import appeng.api.me.util.IGridInterface; + +/** + * Basic ME Grid Interface, informs you of the Grid power status, and other details. + */ +public abstract interface IGridTileEntity +{ + /** + * Do this: + * return new WorldCoord( TileEntity.xCoord, TileEntity.yCoord, TileEntity.zCoord ); + */ + public abstract WorldCoord getLocation(); + + /** + * If your tile entity is valid return true. + */ + public boolean isValid(); + + /** + * Informs you of either true or false. + * if the power feed has stopped, or been continued, only called when changes happens, or when grid updates happen. + */ + public abstract void setPowerStatus(boolean hasPower); + + /** + * Yes if the device has a powered status. + */ + public abstract boolean isPowered(); + + /** + * Return your last grid you got via setGrid. + */ + public IGridInterface getGrid(); + + /** + * Informs you of your new grid, YOU MUST return this via getGrid. + * Store for later. + */ + public void setGrid(IGridInterface gi); + + /** + * Return worldObj + */ + public World getWorld(); +} diff --git a/src/appeng/api/me/tiles/ILocateable.java b/src/appeng/api/me/tiles/ILocateable.java new file mode 100644 index 00000000..18417876 --- /dev/null +++ b/src/appeng/api/me/tiles/ILocateable.java @@ -0,0 +1,10 @@ +package appeng.api.me.tiles; + +public interface ILocateable +{ + /** + * returns the serial for a locateable object. + * @return + */ + long getLocatableSerial(); +} diff --git a/src/appeng/api/me/tiles/IMEPowerStorage.java b/src/appeng/api/me/tiles/IMEPowerStorage.java new file mode 100644 index 00000000..5a118407 --- /dev/null +++ b/src/appeng/api/me/tiles/IMEPowerStorage.java @@ -0,0 +1,34 @@ +package appeng.api.me.tiles; + +/** + * Used to access information about AE's various power accepting blocks for monitoring purposes. + * + */ +public interface IMEPowerStorage { + + /** + * ME power storage asset, pass the amount you want to use, and what you want to use it for. + * @param use + * @param for_what + * @return if you can use it. + */ + boolean useMEEnergy( float use, String for_what ); + + /** + * Add energy to an ME Power storage. + * @param amt that was not added to storage myEnergy = addMEPower( myEnergy ); // pushes your power into the network. + * @return + */ + public double addMEPower( double amt ); + + /** + * returns the current maximum power ( this can change :P ) + */ + public double getMEMaxPower(); + + /** + * returns the current AE Power Level, this may exceed getMEMaxPower() + */ + public double getMECurrentPower(); + +} diff --git a/src/appeng/api/me/tiles/INonSignalBlock.java b/src/appeng/api/me/tiles/INonSignalBlock.java new file mode 100644 index 00000000..eb0fb801 --- /dev/null +++ b/src/appeng/api/me/tiles/INonSignalBlock.java @@ -0,0 +1,9 @@ +package appeng.api.me.tiles; + +/** + * By simply implenting this, the networks can be become aware of a block they touch, but they don't propogate signal or really belong to a network. + * Not sure what it would be used for to be honest beyond the power relay. + */ +public interface INonSignalBlock { + +} diff --git a/src/appeng/api/me/tiles/IOptionalMETile.java b/src/appeng/api/me/tiles/IOptionalMETile.java new file mode 100644 index 00000000..ff0d525d --- /dev/null +++ b/src/appeng/api/me/tiles/IOptionalMETile.java @@ -0,0 +1,14 @@ +package appeng.api.me.tiles; + +/** + * Cables will connect, but signal will not propagate. ( IFulllyOptionalMETile disconnects ) + */ +public interface IOptionalMETile { + + /** + * if false, the signal will not propigate via this tile, remember to use connectivity events. + * @return + */ + public boolean isEnabled(); + +} diff --git a/src/appeng/api/me/tiles/IOrientableTile.java b/src/appeng/api/me/tiles/IOrientableTile.java new file mode 100644 index 00000000..26336736 --- /dev/null +++ b/src/appeng/api/me/tiles/IOrientableTile.java @@ -0,0 +1,26 @@ +package appeng.api.me.tiles; + +import net.minecraftforge.common.ForgeDirection; + +/** + * Please note that none of these methods will cause a block update, + * if you use set ori/spin/cycle, must mark the block for update if it was already sent to the client. + */ +public interface IOrientableTile { + + // returns the main direction for rotation. + ForgeDirection getPrimaryOrientation(); + + // used for up or down orientation to spin the tile around, 0 - 3 clockwise ( probobly ) + int getSpin(); + + // returns the main direction for rotation. + void setPrimaryOrientation( ForgeDirection s ); + + // used for up or down orientation. + void setSpin( int spin ); + + // acts like a wrench was used on it, if a wrench does nothing, this does nothing. + void cycleOrientation(); + +} diff --git a/src/appeng/api/me/tiles/IPriorityTile.java b/src/appeng/api/me/tiles/IPriorityTile.java new file mode 100644 index 00000000..b4243a3f --- /dev/null +++ b/src/appeng/api/me/tiles/IPriorityTile.java @@ -0,0 +1,17 @@ +package appeng.api.me.tiles; + +public interface IPriorityTile +{ + /** + * gets the current priroity, can be negitive or positive. + * implemented by storage systems, and is used for sorting. + * @return + */ + int getPriority(); + + /** + * change the priority. + * @param p + */ + void setPriority( int p ); +} diff --git a/src/appeng/api/me/tiles/IPushable.java b/src/appeng/api/me/tiles/IPushable.java new file mode 100644 index 00000000..f96b6205 --- /dev/null +++ b/src/appeng/api/me/tiles/IPushable.java @@ -0,0 +1,30 @@ +package appeng.api.me.tiles; + +import net.minecraft.item.ItemStack; + +/** + * An IPushable should return what dosn't fit, so that the crafting request cannot complete, + * stalling the action and saving your resources. + */ +public interface IPushable +{ + /** + * is this pushable busy? + * @return + */ + boolean isBusy(); + + /** + * Attempt to send an item. + * @param out + * @return + */ + ItemStack pushItem( ItemStack out ); + + /** + * Test if a push is possible. + * @param out + * @return + */ + boolean canPushItem(ItemStack out); +} diff --git a/src/appeng/api/me/tiles/IStorageAware.java b/src/appeng/api/me/tiles/IStorageAware.java new file mode 100644 index 00000000..c064da5e --- /dev/null +++ b/src/appeng/api/me/tiles/IStorageAware.java @@ -0,0 +1,13 @@ +package appeng.api.me.tiles; + +import appeng.api.IItemList; + +public interface IStorageAware { + + /** + * if your GridTile Implements this interface, the Network will notify it of changes, and send you a list of the contents so you can updates statues, WAY BETTER then polling. + * @param iss + */ + void onNetworkInventoryChange( IItemList iss ); + +} diff --git a/src/appeng/api/me/tiles/IStorageMonitor.java b/src/appeng/api/me/tiles/IStorageMonitor.java new file mode 100644 index 00000000..f8886b10 --- /dev/null +++ b/src/appeng/api/me/tiles/IStorageMonitor.java @@ -0,0 +1,20 @@ +package appeng.api.me.tiles; + +import appeng.api.IAEItemStack; + +public interface IStorageMonitor { + + /** + * Get the item being displayed on the storage monitor, in AEItemstack Form, you can use that to get the equivalent MC ItemStack, if you need it. + * If the quantity is important remember to use getStackSize() on the IAEItemStack,and not ItemStack.stackSize + * @return + */ + IAEItemStack getItem(); + + /** + * Get the current locked state of the access terminal. + * @return + */ + boolean isLocked(); + +} diff --git a/src/appeng/api/me/tiles/ITileCable.java b/src/appeng/api/me/tiles/ITileCable.java new file mode 100644 index 00000000..ed64d54d --- /dev/null +++ b/src/appeng/api/me/tiles/ITileCable.java @@ -0,0 +1,7 @@ +package appeng.api.me.tiles; + +public interface ITileCable { + + public boolean coveredConnections(); + +} diff --git a/src/appeng/api/me/tiles/ITileIOCable.java b/src/appeng/api/me/tiles/ITileIOCable.java new file mode 100644 index 00000000..d63dd2be --- /dev/null +++ b/src/appeng/api/me/tiles/ITileIOCable.java @@ -0,0 +1,30 @@ +package appeng.api.me.tiles; + +import net.minecraft.inventory.IInventory; + +/** + * used to allow you to inspect, and configure a Export / Import / Storage Bus + * Export and Import buses also implement IConfigureableTile, which may be of interest. + */ +public interface ITileIOCable { + + public enum Version { + Basic, Precision, Fuzzy + }; + + /** + * returns one of the above, to indicate which version of the bus it is. + */ + Version getVersion(); + + /** + * Returns an IInventory that represents the configuration. + */ + IInventory getConfiguration(); + + /** + * Returns the name of the bus.. + */ + String getName(); + +} diff --git a/src/appeng/api/me/tiles/ITileInterfaceApi.java b/src/appeng/api/me/tiles/ITileInterfaceApi.java new file mode 100644 index 00000000..f4a2855b --- /dev/null +++ b/src/appeng/api/me/tiles/ITileInterfaceApi.java @@ -0,0 +1,78 @@ +package appeng.api.me.tiles; + +import java.util.List; + +import net.minecraft.item.ItemStack; +import appeng.api.me.util.IMEInventory; +import appeng.api.me.util.InterfaceCraftingResponse; + +/** + * Implemented by the ME Interface + * give direct access to some more complicated logic, in a simpler way, was used for earily LP integration. + */ +public interface ITileInterfaceApi { + + /** + * how much space is available. + * @param i + * @param MaxNeeded, a cut off where you stop caring + * @return totalAmountNeeded + */ + int apiCurrentAvailableSpace(ItemStack i, int MaxNeeded); + + /** + * Attempt to extract an item from the network. + * @param i, item to extract. + * @param doExtract, if you don't its just a simulation. + * @return anyExtracted Items, or null + */ + ItemStack apiExtractNetworkItem(ItemStack i, boolean doExtract); + + /** + * Adds an item to the network + * @param i + * @param doAdd, or simulate + * @return any items that couldn't be added, or nul + */ + ItemStack apiAddNetworkItem(ItemStack i, boolean doAdd); + + /** + * returns a list of ItemStacks that are contined in the network. + * @return + */ + List apiGetNetworkContents(); + + /** + * get access to the networks IMEInventory. + * @return + */ + IMEInventory getApiArray(); + + /** + * get a list of items that can be crafted by the network. + * @return + */ + List getCraftingOptions(); + + /** + * get access to the crafting patterns. + * @param req + * @return + */ + List findCraftingPatterns( ItemStack req ); + + /** + * issue a new crafting request. + * @param req + * @param enableRecursive + * @return + */ + InterfaceCraftingResponse requestCrafting( ItemStack req, boolean enableRecursive ); + + /** + * if there is anything at all available it returns true. + * @return + */ + boolean containsItems(); + +} diff --git a/src/appeng/api/me/tiles/InterfaceCraftingPattern.java b/src/appeng/api/me/tiles/InterfaceCraftingPattern.java new file mode 100644 index 00000000..3ba69b43 --- /dev/null +++ b/src/appeng/api/me/tiles/InterfaceCraftingPattern.java @@ -0,0 +1,19 @@ +package appeng.api.me.tiles; + +import java.util.List; + +import net.minecraft.item.ItemStack; + +public class InterfaceCraftingPattern { + + /** + * list of all the inputs. + */ + public List Inputs; + + /** + * the output of the pattern. + */ + public ItemStack Output; + +} diff --git a/src/appeng/api/me/util/Grid.java b/src/appeng/api/me/util/Grid.java new file mode 100644 index 00000000..74a81349 --- /dev/null +++ b/src/appeng/api/me/util/Grid.java @@ -0,0 +1,84 @@ +package appeng.api.me.util; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import appeng.api.me.tiles.IGridTileEntity; + +/** + * ME Network, aka Grid related features and functionality. + */ +public class Grid +{ + /** + * Attempts to find a grid interface for the specified location. + * @param w + * @param x + * @param y + * @param z + * @return interfaceForGrid + */ + public static IGridInterface getGridInterface(World w, int x, int y, int z) + { + IGridTileEntity te = getGridEntity(w, x, y, z); + + if (te != null) + { + return te.getGrid(); + } + + return null; + } + + /** + * Simple test to see if the tile at the specified location is in fact a grid entity. + * @param w + * @param x + * @param y + * @param z + * @return isTileGridEntity + */ + public static boolean isGridEntity(World w, int x, int y, int z) + { + return getGridEntity(w, x, y, z) != null; + } + + /** + * Returns the grid entity at the given location, or null if its not a grid entity. + * @param w + * @param x + * @param y + * @param z + * @return gridEntity + */ + public static IGridTileEntity getGridEntity(World w, int x, int y, int z) + { + TileEntity te = w.getBlockTileEntity(x, y, z); + + if (te instanceof IGridTileEntity) + { + return (IGridTileEntity)te; + } + + return null; + } + + /** + * Tests if the given grid entity is on a Network. + * @param w + * @param x + * @param y + * @param z + * @return isOnNetwork + */ + public static boolean isOnGrid(World w, int x, int y, int z) + { + IGridTileEntity te = getGridEntity(w, x, y, z); + + if (te != null) + { + return te.getGrid() != null; + } + + return false; + } +} diff --git a/src/appeng/api/me/util/IAssemblerCluster.java b/src/appeng/api/me/util/IAssemblerCluster.java new file mode 100644 index 00000000..39902290 --- /dev/null +++ b/src/appeng/api/me/util/IAssemblerCluster.java @@ -0,0 +1,37 @@ +package appeng.api.me.util; + +import net.minecraft.tileentity.TileEntity; + +/** + * Definition for a MAC + * + */ +public interface IAssemblerCluster { + + /** + * cycles the cpus, should be called once a tick, if called more, crafting will accelerate. + */ + public void cycleCpus(); + + /** + * Tells the MAC one of the cpus was used. + */ + void addCraft(); + + /** + * is there a CPU available for Crafting? + * @return hasCPUReady + */ + boolean canCraft(); + + /** + * Gets a TileAssembler from the MAC + * @param assemblerOffset + * @return TileEntity for that Assembler or Null + */ + TileEntity getAssembler( int assemblerOffset ); + + public int getLastOffset(); + + public void setLastOffset( int x ); +} diff --git a/src/appeng/api/me/util/IAssemblerPattern.java b/src/appeng/api/me/util/IAssemblerPattern.java new file mode 100644 index 00000000..56e1a098 --- /dev/null +++ b/src/appeng/api/me/util/IAssemblerPattern.java @@ -0,0 +1,78 @@ +package appeng.api.me.util; + +import java.util.List; + +import appeng.api.IItemList; +import appeng.api.me.tiles.IPushable; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +/** + * Interact with the internals of assembler patterns, get this via Util.getAssemblerPattern(...) + */ +public interface IAssemblerPattern +{ + + IAssemblerCluster getCluster(); + + /** Returns a 3x3 matrix of nulls or ItemStacks, or null if it is not included. */ + ItemStack[] getCraftingMatrix(); + + /** + * Same as getCraftingMatrix(), but gets a crafting inventory for real crafting. + * + * Item pool is optional, null will work, but it won't be able to edit items... + */ + InventoryCrafting getCraftingInv( World w, IMEInventory itemPool, List missing, List used, IItemList all ); + + /** Returns a ItemStack, if the pattern is encoded, this will ALWAYS have a value. */ + ItemStack getOutput(); + + /** Returns true if there is a pattern encoded. */ + boolean isEncoded(); + + /** + * Encode a pattern. + * craftingMatrix - accepts a 3x3 grid of ItemStacks and Nulls. + * output - accepts a single ItemStack, NEVER SEND NULL + */ + void encodePattern(ItemStack[] craftingMatrix, ItemStack output); + + /** + * I have no idea what the World is for, its just part of IRecipe... + */ + boolean isCraftable(World w); + + /** + * Returns a condensed list of requirements. + * + * Example: sticks, will return a single stack of 2, rather then two stacks of 1. + * The same Item will not show more than one stack. + */ + public List condensedRequirements(); + + /** Returns the Tile Entity for the interface... */ + List getInterface(); + + /** Sets the Tile Entity for the interface... */ + void setInterface(IPushable a); + + /** returns the output of the pattern */ + ItemStack getRecipeOutput( InventoryCrafting ic, World w ); + + /** returns the recipe for the patterns */ + IRecipe getMatchingRecipe( InventoryCrafting ic, World w ); + + /** + * Compare to Patterns + * @param obj + * @return + */ + @Override + public boolean equals(Object obj); + +} + diff --git a/src/appeng/api/me/util/IConfigManager.java b/src/appeng/api/me/util/IConfigManager.java new file mode 100644 index 00000000..42f3ae4c --- /dev/null +++ b/src/appeng/api/me/util/IConfigManager.java @@ -0,0 +1,10 @@ +package appeng.api.me.util; + +import appeng.api.config.IConfigEnum; +import appeng.api.me.tiles.IConfigureableTile; + +public interface IConfigManager extends IConfigureableTile +{ + + IConfigEnum getSetting( String sName ); +} diff --git a/src/appeng/api/me/util/ICraftRequest.java b/src/appeng/api/me/util/ICraftRequest.java new file mode 100644 index 00000000..2812e514 --- /dev/null +++ b/src/appeng/api/me/util/ICraftRequest.java @@ -0,0 +1,9 @@ +package appeng.api.me.util; + +/** + * Pretty much just a place holder right now + * + */ +public interface ICraftRequest { + +} diff --git a/src/appeng/api/me/util/ICraftWatcher.java b/src/appeng/api/me/util/ICraftWatcher.java new file mode 100644 index 00000000..2ba84108 --- /dev/null +++ b/src/appeng/api/me/util/ICraftWatcher.java @@ -0,0 +1,12 @@ +package appeng.api.me.util; + +/** + * Not used. + * + */ +public interface ICraftWatcher { + + void markChainCrafted(); + void markComplete( ICraftRequest cr ); + +} diff --git a/src/appeng/api/me/util/IGridCache.java b/src/appeng/api/me/util/IGridCache.java new file mode 100644 index 00000000..3dce582b --- /dev/null +++ b/src/appeng/api/me/util/IGridCache.java @@ -0,0 +1,46 @@ +package appeng.api.me.util; + +import net.minecraft.nbt.NBTTagCompound; + +/** + * + * Allows you to cache information on the grid, for usage later, its up to you how you want to deal with saving/loading/resetting. + * + * Any Class that implements this, should have a default constructor that takes no arguments. + * + * Register this with Util.getAppEngApi().registerGridCache( MyGridCache.class ); + * + */ +public interface IGridCache { + + /** + * Called each time a network is reset ( changed ), the grid will persist your classes instance, but call this method. + * @param grid + */ + void reset( IGridInterface grid ); + + /** + * Called each tick for the controller, allows you to have active network wide behaviors. + * @param grid + */ + void onUpdateTick( IGridInterface grid ); + + /** + * used to uniquely identify your cache when saving/loading + * @return + */ + String getCacheName(); + + /** + * Save your caches state if necessary, if no saving is required, return null. + * @return + */ + NBTTagCompound savetoNBTData(); + + /** + * Load save cache data, this is called when a controller is loaded with previously saved data if there was no data, data will be an empty tag. + * @param data + */ + void loadfromNBTData( NBTTagCompound data ); + +} diff --git a/src/appeng/api/me/util/IGridInterface.java b/src/appeng/api/me/util/IGridInterface.java new file mode 100644 index 00000000..441984f1 --- /dev/null +++ b/src/appeng/api/me/util/IGridInterface.java @@ -0,0 +1,219 @@ +package appeng.api.me.util; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import appeng.api.IAEItemStack; +import appeng.api.TileRef; +import appeng.api.exceptions.AppEngTileMissingException; +import appeng.api.me.tiles.IGridMachine; +import appeng.api.me.tiles.IGridTileEntity; +import appeng.api.me.tiles.IPushable; + +/** + * Lets you access network related features. You will mostly care about "getCellArray()" which returns the IMEInventory for the entire network... + */ +public interface IGridInterface +{ + /** + * Issue a new crafting request. + * @param whatToCraft + * @param showInMonitor + * @param enableRecursion + * @return the ICraftRequest + * @throws AppEngTileMissingException + */ + public ICraftRequest craftingRequest( ItemStack whatToCraft, boolean showInMonitor, boolean enableRecursion ) throws AppEngTileMissingException; + + /** + * deprecated version of creaftingRequest. + * @param what + * @return + * @throws AppEngTileMissingException + */ + public ICraftRequest craftingRequest( ItemStack what ) throws AppEngTileMissingException; + + /** + * opens the crafting gui. + * @param pmp + * @param gte + * @param s + * @throws AppEngTileMissingException + */ + public void craftGui( EntityPlayerMP pmp, IGridTileEntity gte, ItemStack s ) throws AppEngTileMissingException; + + /** + * Updates the interface requested, used internally + * @param te + */ + public void requestUpdate( IGridTileEntity te ); + + /** + * returns a list of all machines on the grid. + * @return + */ + List< TileRef > getMachines(); + + /** + * Labeled version for debugging... + */ + boolean useMEEnergy(float use, String for_what); + + /** + * returns energy to the system to prevent endless energy sinks. + */ + void refundMEEnergy( float use, String for_what ); + + /** + * Reports previous 20 ticks avg of energy usage. + * @return + */ + public float getPowerUsageAvg(); + + /** + * this is used for standard items, anything else just use useMEEnergy. + * @param items + * @param multipler + * @return + */ + int usePowerForAddition(int items, int multipler); + + /** + * returns a single IMEInventory that represents the entire networks. + * @return + */ + public IMEInventoryHandler getCellArray(); + + /** + * returns a single IMEInventory that represents the entire network, and all crafting available. + * @return + */ + public IMEInventoryHandler getFullCellArray(); + + /** + * add which users should be notified of terminal updates. + * @param p + */ + void addViewingPlayer(EntityPlayer p); + + /** + * remove which users should be notified of terminal updates. + * @param p + */ + void rmvViewingPlayer(EntityPlayer p); + + /** + * add which users should be notified of crafting queue updates. + * @param p + */ + void addCraftingPlayer(EntityPlayer p); + + /** + * remove which users should be notified of crafting queue updates. + * @param p + */ + void rmvCraftingPlayer(EntityPlayer p); + + /** + * aquire the controller tile entity. + * @return + */ + public TileEntity getController(); + + /** + * create a waiting job. + * @param what + * @return + */ + ICraftRequest waitingRequest(ItemStack what); + + /** + * creates a crafting job to push the item out of IPushable, and to enable crafting to acocomplish this goal. + * @param willAdd + * @param out + * @param allowCrafting + * @return + */ + ICraftRequest pushRequest( ItemStack willAdd, IPushable out, boolean allowCrafting ); + + /** + * is the grid valid? + * @return + */ + public boolean isValid(); + + /** + * tell AE to re-examin items in the waiting list. + */ + void resetWaitingQueue(); + + /** + * craftable items + * @return + */ + IMEInventoryHandler getCraftableArray(); + + /** + * get a numeric id for this grid, used internally for cable animations, and not much else. + * @return + */ + public int getGridIndex(); + + /** + * Try to find the pattern for the item in question. + * @param req + * @return + */ + public IAssemblerPattern getPatternFor(ItemStack req); + + /** + * Inform the network that power costs have changed. + */ + public void triggerPowerUpdate(); + + /** + * Inform the netowrk that these items were removed from storage ( don't do this for items remove though the grid, it already knows about those. ) + * @param removed + */ + public void notifyExtractItems(IAEItemStack removed); + + /** + * Inform the network that these items were added to storage ( don't do this for items added via the grid, it already knows about those. ) + * @param vo + */ + public void notifyAddItems(IAEItemStack vo); + + /** + * return a cache by its identifier ( the number you get when you register your cache with AE ) + * @param id + * @return + */ + public IGridCache getCacheByID( int id ); + + /** + * Potential future use, for now just returns the network encryption key. + * @return + */ + public String getName(); + + /** + * inform the network that energy was transfered between two nodes on the network, + * this will be used to calculates future information, but also causes the network + * to flash presently. + * + * this will automatically be handled by the standard extractItem / addItem API in the future, only + * Processes that skip the vanilla AE storage system should use this. + * + * @param a + * @param b + * @param amt + */ + void signalEnergyTransfer(IGridTileEntity a, IGridTileEntity b, float amt); + + @Override + public boolean equals(Object obj); + +} diff --git a/src/appeng/api/me/util/ILocationPattern.java b/src/appeng/api/me/util/ILocationPattern.java new file mode 100644 index 00000000..49b62cf3 --- /dev/null +++ b/src/appeng/api/me/util/ILocationPattern.java @@ -0,0 +1,12 @@ +package appeng.api.me.util; + +import appeng.api.WorldCoord; + +/** + * Lets you Access Internal Location Pattern data. + */ +public interface ILocationPattern { + WorldCoord getLocation(); + + void setLocation(int x, int y, int z); +} diff --git a/src/appeng/api/me/util/IMEInventory.java b/src/appeng/api/me/util/IMEInventory.java new file mode 100644 index 00000000..3e369149 --- /dev/null +++ b/src/appeng/api/me/util/IMEInventory.java @@ -0,0 +1,77 @@ +package appeng.api.me.util; + +import appeng.api.IAEItemStack; +import appeng.api.IItemList; + +/** + * Lets you access Internal Cell Inventories. + */ +public interface IMEInventory +{ + /** + * The number of different item types stored in inventory. + */ + public long storedItemTypes(); + + /** + * The number of stored items total, regardless of type. + */ + public long storedItemCount(); + + /** + * The estimated number of additional items this inventory can hold, regardless of type. + */ + public long remainingItemCount(); + + /** + * The estimated number of additional types the inventory could hold. + */ + public long remainingItemTypes(); + + /** + * True or False if this item is inside this inventory. + */ + public boolean containsItemType(IAEItemStack i); + + /** + * The total number of types holdable in this inventory. + */ + public long getTotalItemTypes(); + + /** + * Returns how many of this item are in the inventory, regardless of a how many stacks / cells or anything else. + */ + public long countOfItemType(IAEItemStack i); + + /** + * Adds input, to the inventory, and returns items not added, complete failure yields a copy of the stack that was passed. + */ + public IAEItemStack addItems( IAEItemStack input ); + + /** + * Attempts to extract the requested item, in the count specified by the request, returns items extracted, complete failure yields NULL. + */ + public IAEItemStack extractItems( IAEItemStack request ); + + // DO NOT USE ItemStack.split, these are for information purpose ONLY! + // I you wan to remove items from the cell, use extractItemss + + /** + * Returns a list of all available items, with stackSize set to the real amount, without stack limits. + */ + public IItemList getAvailableItems( IItemList out ); + + /** + * Returns a list of all available items, with stackSize set to the real amount, without stack limits. + */ + public IItemList getAvailableItems(); + + /** + * Identical to addItems(...) but it don't change anything, its just a simulation. + * this is used when dealing with pipes/tubes, and routing. + */ + public IAEItemStack calculateItemAddition(IAEItemStack stack); + + // calculates available space for a specific item. + public long getAvailableSpaceByItem( IAEItemStack i, long maxNeeded ); +} diff --git a/src/appeng/api/me/util/IMEInventoryHandler.java b/src/appeng/api/me/util/IMEInventoryHandler.java new file mode 100644 index 00000000..947f5178 --- /dev/null +++ b/src/appeng/api/me/util/IMEInventoryHandler.java @@ -0,0 +1,76 @@ +package appeng.api.me.util; + +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import appeng.api.IAEItemStack; +import appeng.api.IItemList; +import appeng.api.config.FuzzyMode; +import appeng.api.config.IConfigEnum; +import appeng.api.config.ItemFlow; +import appeng.api.config.ListMode; + +public interface IMEInventoryHandler extends IMEInventory { + + public ItemFlow getFlow(); + public void setFlow( ItemFlow p ); + + public int getPriority(); + public void setPriority( int p ); + + /** + * Returns estimated number of total bytes represented by the inventory, used mainly for display. + */ + public long totalBytes(); + + /** + * Returns estimated number of free bytes represented by inventory, used mainly for display. + */ + public long freeBytes(); + + /** + * Returns number of used bytes represented by the inventory, used mainly for display. + */ + public long usedBytes(); + + /** + * The number of items you could add before the freeBytes() decreases. + */ + public long unusedItemCount(); + + /** + * True of False, if you could add a new item type. + */ + public boolean canHoldNewItem(); + + /** + * This tells you where it found your cell, so if your cell changes, you should update this block... + */ + void setUpdateTarget(TileEntity e); + + List getPreformattedItems(); + void setPreformattedItems(IItemList in, FuzzyMode mode, ListMode m); + + boolean isPreformatted(); + boolean isFuzzyPreformatted(); + + ListMode getListMode(); + FuzzyMode getFuzzyModePreformatted(); + + void setFuzzyPreformatted( boolean nf ); + + public void setName(String name); + String getName(); + + void setGrid( IGridInterface grid ); + IGridInterface getGrid(); + + void setParent( IMEInventoryHandler p ); + IMEInventoryHandler getParent(); + + void removeGrid(IGridInterface grid, IMEInventoryHandler ignore, List duplicates ); + public void validate( List duplicates ); + public boolean canAccept(IAEItemStack input); + +} diff --git a/src/appeng/api/me/util/IMEInventoryUtil.java b/src/appeng/api/me/util/IMEInventoryUtil.java new file mode 100644 index 00000000..e43bce07 --- /dev/null +++ b/src/appeng/api/me/util/IMEInventoryUtil.java @@ -0,0 +1,19 @@ +package appeng.api.me.util; + +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.World; +import appeng.api.IAEItemStack; +import appeng.api.IItemList; + +public interface IMEInventoryUtil { + + // ignores meta data - is always Fuzzy... + // will only remove single items, this ignores your stack size... + public ItemStack extractItemsByRecipe(World w, IRecipe r, ItemStack output, InventoryCrafting ci, ItemStack providedTemplate, int slot, IItemList all ); + + // ignores meta data - is always Fuzzy... + //public ItemStack extractItemsByType( ItemStack is ); // will only remove single items, this ignores your stack size... + +} diff --git a/src/appeng/api/me/util/InterfaceCraftingResponse.java b/src/appeng/api/me/util/InterfaceCraftingResponse.java new file mode 100644 index 00000000..6a50915e --- /dev/null +++ b/src/appeng/api/me/util/InterfaceCraftingResponse.java @@ -0,0 +1,13 @@ +package appeng.api.me.util; + +import java.util.List; + +import net.minecraft.item.ItemStack; + +public class InterfaceCraftingResponse { + + public ItemStack Request; + + public List UsedMaterials; + +} diff --git a/src/tconstruct/TConstruct.java b/src/tconstruct/TConstruct.java index 04c7d417..c1520eca 100644 --- a/src/tconstruct/TConstruct.java +++ b/src/tconstruct/TConstruct.java @@ -6,16 +6,16 @@ import net.minecraftforge.common.MinecraftForge; import tconstruct.client.event.EventCloakRender; import tconstruct.common.TContent; import tconstruct.common.TProxyCommon; -import tconstruct.compat.BOP; -import tconstruct.compat.Tforest; -import tconstruct.compat.dimensions.dimblacklist; import tconstruct.library.TConstructRegistry; import tconstruct.library.crafting.Detailing; import tconstruct.library.crafting.LiquidCasting; import tconstruct.library.util.TabTools; -import tconstruct.util.PHConstruct; import tconstruct.util.TCraftingHandler; import tconstruct.util.TEventHandler; +import tconstruct.util.config.BOPConfig; +import tconstruct.util.config.DimensionBlacklist; +import tconstruct.util.config.PHConstruct; +import tconstruct.util.config.TwilightForestConfig; import tconstruct.util.landmine.behavior.Behavior; import tconstruct.util.landmine.behavior.stackCombo.SpecialStackHandler; import tconstruct.util.player.TPlayerHandler; @@ -131,7 +131,7 @@ public class TConstruct //if (MinecraftServer.getServer().getMinecraftVersion().equals("1.6.4")) /*ComparableVersion cv = new ComparableVersion(new CallableMinecraftVersion(null).minecraftVersion()); ComparableVersion compare = new ComparableVersion("1.6.4"); - if (compare.compareTo(cv) > 0)*/ //<-- Probably not right + if (compare.compareTo(cv) > 0)*///<-- Probably not right if (new CallableMinecraftVersion(null).minecraftVersion().equals("1.6.4")) { MapGenStructureIO.func_143031_a(ComponentToolWorkshop.class, "TConstruct:ToolWorkshopStructure"); @@ -158,9 +158,9 @@ public class TConstruct } content.intermodCommunication(); - Tforest.initProps(PHConstruct.cfglocation); - BOP.initProps(PHConstruct.cfglocation); - dimblacklist.getbaddimensions(); + TwilightForestConfig.initProps(PHConstruct.cfglocation); + BOPConfig.initProps(PHConstruct.cfglocation); + DimensionBlacklist.getbaddimensions(); GameRegistry.registerWorldGenerator(new SlimeIslandGen(TContent.slimePool.blockID, 0)); } diff --git a/src/tconstruct/blocks/CraftingSlab.java b/src/tconstruct/blocks/CraftingSlab.java index 1f16f4f3..b4273d79 100644 --- a/src/tconstruct/blocks/CraftingSlab.java +++ b/src/tconstruct/blocks/CraftingSlab.java @@ -25,7 +25,7 @@ import tconstruct.common.TContent; import tconstruct.common.TProxyCommon; import tconstruct.library.TConstructRegistry; import tconstruct.library.blocks.InventoryBlock; -import tconstruct.util.PHConstruct; +import tconstruct.util.config.PHConstruct; public class CraftingSlab extends InventoryBlock { diff --git a/src/tconstruct/blocks/GlassBlockConnected.java b/src/tconstruct/blocks/GlassBlockConnected.java index b8be33f8..ff685f89 100644 --- a/src/tconstruct/blocks/GlassBlockConnected.java +++ b/src/tconstruct/blocks/GlassBlockConnected.java @@ -1,7 +1,7 @@ package tconstruct.blocks; import tconstruct.library.TConstructRegistry; -import tconstruct.util.PHConstruct; +import tconstruct.util.config.PHConstruct; import net.minecraft.block.Block; import net.minecraft.block.material.Material; diff --git a/src/tconstruct/blocks/GlassBlockConnectedMeta.java b/src/tconstruct/blocks/GlassBlockConnectedMeta.java index 479526df..40387ae2 100644 --- a/src/tconstruct/blocks/GlassBlockConnectedMeta.java +++ b/src/tconstruct/blocks/GlassBlockConnectedMeta.java @@ -2,7 +2,7 @@ package tconstruct.blocks; import java.util.List; -import tconstruct.util.PHConstruct; +import tconstruct.util.config.PHConstruct; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; diff --git a/src/tconstruct/blocks/GlassPaneConnected.java b/src/tconstruct/blocks/GlassPaneConnected.java index 76e691a3..54c434e6 100644 --- a/src/tconstruct/blocks/GlassPaneConnected.java +++ b/src/tconstruct/blocks/GlassPaneConnected.java @@ -1,6 +1,6 @@ package tconstruct.blocks; -import tconstruct.util.PHConstruct; +import tconstruct.util.config.PHConstruct; import java.util.List; diff --git a/src/tconstruct/blocks/SmelteryBlock.java b/src/tconstruct/blocks/SmelteryBlock.java index d76bf092..17868435 100644 --- a/src/tconstruct/blocks/SmelteryBlock.java +++ b/src/tconstruct/blocks/SmelteryBlock.java @@ -3,6 +3,15 @@ package tconstruct.blocks; import java.util.List; import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +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.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; import tconstruct.TConstruct; import tconstruct.blocks.logic.MultiServantLogic; import tconstruct.blocks.logic.SmelteryDrainLogic; @@ -14,17 +23,6 @@ import tconstruct.library.util.IFacingLogic; import tconstruct.library.util.IMasterLogic; import tconstruct.library.util.IServantLogic; -import net.minecraft.block.material.Material; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLiving; -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.Icon; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - public class SmelteryBlock extends InventoryBlock { Random rand; @@ -41,11 +39,11 @@ public class SmelteryBlock extends InventoryBlock /* Rendering */ - /*@Override + @Override public int getRenderType () { return SmelteryRender.smelteryModel; - }*/ + } @Override public String[] getTextureNames () @@ -186,15 +184,6 @@ public class SmelteryBlock extends InventoryBlock return !isActive(world, x, y, z) ? 0 : 9; } - //@Override - /*public void getSubBlocks (int id, CreativeTabs tab, List list) - { - for (int iter = 0; iter < 9; iter++) - { - list.add(new ItemStack(id, 1, iter)); - } - }*/ - @Override public Object getModInstance () { @@ -233,7 +222,7 @@ public class SmelteryBlock extends InventoryBlock } return new MultiServantLogic(); } - + @Override public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack) { @@ -274,7 +263,7 @@ public class SmelteryBlock extends InventoryBlock } else if (logic instanceof IMasterLogic) { - ((IMasterLogic) logic).notifyChange(x, y, z); + ((IMasterLogic) logic).notifyChange(null, x, y, z); } } } diff --git a/src/tconstruct/blocks/TankAirBlock.java b/src/tconstruct/blocks/TankAirBlock.java new file mode 100644 index 00000000..472db131 --- /dev/null +++ b/src/tconstruct/blocks/TankAirBlock.java @@ -0,0 +1,22 @@ +package tconstruct.blocks; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import tconstruct.blocks.logic.TankAirLogic; + +public class TankAirBlock extends BlockContainer +{ + + public TankAirBlock(int id, Material material) + { + super(id, material); + } + + @Override + public TileEntity createNewTileEntity (World world) + { + return new TankAirLogic(); + } +} diff --git a/src/tconstruct/blocks/ToolStationBlock.java b/src/tconstruct/blocks/ToolStationBlock.java index cb2204f1..19478be5 100644 --- a/src/tconstruct/blocks/ToolStationBlock.java +++ b/src/tconstruct/blocks/ToolStationBlock.java @@ -11,7 +11,7 @@ import tconstruct.client.block.TableRender; import tconstruct.common.TContent; import tconstruct.library.TConstructRegistry; import tconstruct.library.blocks.InventoryBlock; -import tconstruct.util.PHConstruct; +import tconstruct.util.config.PHConstruct; import net.minecraft.block.Block; import net.minecraft.block.material.Material; diff --git a/src/tconstruct/blocks/component/SmelteryComponent.java b/src/tconstruct/blocks/component/SmelteryComponent.java new file mode 100644 index 00000000..0a3bb0b5 --- /dev/null +++ b/src/tconstruct/blocks/component/SmelteryComponent.java @@ -0,0 +1,234 @@ +package tconstruct.blocks.component; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import tconstruct.library.component.LogicComponent; +import tconstruct.library.component.MultiFluidTank; +import tconstruct.library.crafting.Smeltery; +import tconstruct.library.util.CoordTuple; + +public class SmelteryComponent extends LogicComponent +{ + final IInventory master; + final SmelteryScan structure; + final MultiFluidTank multitank; + int maxTemp; + + public int fuelTicks; + public int fuelGague; + public int fuelAmount; + boolean inUse; + + public int[] activeTemps = new int[0]; + public int[] meltingTemps = new int[0]; + + CoordTuple activeLavaTank; + + public SmelteryComponent(IInventory inventory, SmelteryScan structure, MultiFluidTank multitank, int maxTemp) + { + master = inventory; + this.structure = structure; + this.multitank = multitank; + this.maxTemp = maxTemp; + } + + public void update () + { + /*if (useTime > 0 && inUse) + useTime -= 3;*/ + + updateFuelGague(); + } + + public void adjustSize (int size, boolean forceAdjust) + { + if (size != activeTemps.length || forceAdjust) + { + int[] tempActive = activeTemps; + activeTemps = new int[size]; + int activeLength = tempActive.length > activeTemps.length ? activeTemps.length : tempActive.length; + System.arraycopy(tempActive, 0, activeTemps, 0, activeLength); + + int[] tempMelting = meltingTemps; + meltingTemps = new int[size]; + int meltingLength = tempMelting.length > meltingTemps.length ? meltingTemps.length : tempMelting.length; + System.arraycopy(tempMelting, 0, meltingTemps, 0, meltingLength); + + if (activeTemps.length > 0 && activeTemps.length > tempActive.length) + { + for (int i = tempActive.length; i < activeTemps.length; i++) + { + activeTemps[i] = 20; + meltingTemps[i] = 20; + } + } + } + } + + public void heatItems () + { + if (fuelTicks > 0) + { + boolean hasUse = false; + for (int i = 0; i < meltingTemps.length; i++) + { + fuelTicks--; + if (fuelTicks <= 0) + break; + + ItemStack slot = master.getStackInSlot(i); + if (meltingTemps[i] > 20 && slot != null) + { + hasUse = true; + if (activeTemps[i] < maxTemp && activeTemps[i] < meltingTemps[i]) + { + activeTemps[i] += 1; + } + else if (activeTemps[i] >= meltingTemps[i] && !world.isRemote) + { + FluidStack result = getResultFor(slot); + if (result != null) + { + if (multitank.addFluidToTank(result, false)) + { + master.setInventorySlotContents(i, null); + activeTemps[i] = 20; + ArrayList alloys = Smeltery.mixMetals(multitank.fluidlist); + for (int al = 0; al < alloys.size(); al++) + { + FluidStack liquid = (FluidStack) alloys.get(al); + multitank.addFluidToTank(liquid, true); + } + master.onInventoryChanged(); + } + } + } + + } + + else + activeTemps[i] = 20; + } + inUse = hasUse; + } + } + + void updateFuelGague () + { + if (activeLavaTank == null || fuelTicks > 0) + return; + + if (!world.blockExists(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z)) + { + fuelAmount = 0; + fuelGague = 0; + return; + } + + TileEntity tankContainer = world.getBlockTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z); + if (tankContainer == null) + { + fuelAmount = 0; + fuelGague = 0; + return; + } + + if (tankContainer instanceof IFluidHandler) + { + FluidStack liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, drainFuelAmount(), false); + if (liquid != null && liquid.getFluid().getBlockID() == Block.lavaStill.blockID) + { + liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, drainFuelAmount(), true); + fuelTicks += liquid.amount * 15; + + FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN); + liquid = info[0].fluid; + int capacity = info[0].capacity; + if (liquid != null) + { + fuelAmount = liquid.amount; + fuelGague = liquid.amount * 52 / capacity; + } + else + { + fuelAmount = 0; + fuelGague = 0; + } + } + else + { + boolean foundTank = false; + int iter = 0; + while (!foundTank) + { + CoordTuple possibleTank = structure.lavaTanks.get(iter); + TileEntity newTankContainer = world.getBlockTileEntity(possibleTank.x, possibleTank.y, possibleTank.z); + if (newTankContainer instanceof IFluidHandler) + { + FluidStack newliquid = ((IFluidHandler) newTankContainer).drain(ForgeDirection.UNKNOWN, drainFuelAmount(), false); + if (newliquid != null && newliquid.getFluid().getBlockID() == Block.lavaStill.blockID && newliquid.amount > 0) + { + foundTank = true; + activeLavaTank = possibleTank; + iter = structure.lavaTanks.size(); + + FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN); + liquid = info[0].fluid; + int capacity = info[0].capacity; + if (liquid != null) + { + fuelAmount = liquid.amount; + fuelGague = liquid.amount * 52 / capacity; + } + else + { + fuelAmount = 0; + fuelGague = 0; + } + } + } + iter++; + if (iter >= structure.lavaTanks.size()) + foundTank = true; + } + } + } + } + + private int drainFuelAmount () + { + int amount = activeTemps.length / 3; + if (amount < 150) + amount = 150; + return amount; + } + + public FluidStack getResultFor (ItemStack stack) + { + return Smeltery.instance.getSmelteryResult(stack); + } + + public int getInternalTemperature () + { + return maxTemp; + } + + public int getTempForSlot (int slot) + { + return activeTemps[slot]; + } + + public int getMeltingPointForSlot (int slot) + { + return meltingTemps[slot]; + } +} diff --git a/src/tconstruct/blocks/component/SmelteryScan.java b/src/tconstruct/blocks/component/SmelteryScan.java new file mode 100644 index 00000000..a224509f --- /dev/null +++ b/src/tconstruct/blocks/component/SmelteryScan.java @@ -0,0 +1,68 @@ +package tconstruct.blocks.component; + +import java.util.ArrayList; +import java.util.Iterator; + +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; +import tconstruct.common.TContent; +import tconstruct.library.component.TankLayerScan; +import tconstruct.library.util.CoordTuple; +import tconstruct.library.util.IServantLogic; + +public class SmelteryScan extends TankLayerScan +{ + public ArrayList lavaTanks = new ArrayList(); + + public SmelteryScan(TileEntity te, Block... id) + { + super(te, id); + } + + @Override + public void checkValidStructure () + { + lavaTanks.clear(); + super.checkValidStructure(); + } + + @Override + protected boolean checkServant (int x, int y, int z) + { + Block block = Block.blocksList[world.getBlockId(x, y, z)]; + if (block == null || block.isAirBlock(world, x, y, z) || !isValidBlock(x, y, z)) + return false; + + if (!block.hasTileEntity(world.getBlockMetadata(x, y, z))) + return false; + + TileEntity be = world.getBlockTileEntity(x, y, z); + if (be instanceof IServantLogic) + { + boolean ret = ((IServantLogic) be).setPotentialMaster(this.imaster, this.world, x, y, z); + if (ret && block == TContent.lavaTank) + lavaTanks.add(new CoordTuple(x, y, z)); + return ret; + } + + return false; + } + + protected void addAirBlock (int x, int y, int z) + { + super.addAirBlock(x, y, z); + world.setBlock(x, y, z, Block.leaves.blockID); + } + + public void cleanup() + { + System.out.println("Structure cleanup activated. Air blocks: "+airCoords.size()); + super.cleanup(); + Iterator i = airCoords.iterator(); + while (i.hasNext()) + { + CoordTuple coord = (CoordTuple) i.next(); + world.setBlockToAir(coord.x, coord.y, coord.z); + } + } +} diff --git a/src/tconstruct/blocks/component/TankAirComponent.java b/src/tconstruct/blocks/component/TankAirComponent.java new file mode 100644 index 00000000..b6d02407 --- /dev/null +++ b/src/tconstruct/blocks/component/TankAirComponent.java @@ -0,0 +1,20 @@ +package tconstruct.blocks.component; + +import java.util.ArrayList; + +import net.minecraftforge.fluids.FluidStack; +import tconstruct.library.component.MultiFluidTank; + +public class TankAirComponent extends MultiFluidTank +{ + public TankAirComponent() {} + public TankAirComponent(int i) + { + super(i); + } + + public void overrideFluids(ArrayList fluids) + { + fluidlist = fluids; + } +} diff --git a/src/tconstruct/blocks/logic/AdaptiveSmelteryLogic.java b/src/tconstruct/blocks/logic/AdaptiveSmelteryLogic.java index aa85cfbe..26f43304 100644 --- a/src/tconstruct/blocks/logic/AdaptiveSmelteryLogic.java +++ b/src/tconstruct/blocks/logic/AdaptiveSmelteryLogic.java @@ -6,25 +6,71 @@ import java.util.List; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; +import tconstruct.TConstruct; +import tconstruct.blocks.component.SmelteryComponent; +import tconstruct.blocks.component.SmelteryScan; import tconstruct.common.TContent; import tconstruct.library.blocks.AdaptiveInventoryLogic; import tconstruct.library.component.IComponentHolder; import tconstruct.library.component.LogicComponent; import tconstruct.library.component.MultiFluidTank; -import tconstruct.library.component.SmelteryComponent; -import tconstruct.library.component.TankLayerScan; import tconstruct.library.util.IActiveLogic; import tconstruct.library.util.IMasterLogic; +import tconstruct.library.util.IServantLogic; public class AdaptiveSmelteryLogic extends AdaptiveInventoryLogic implements IActiveLogic, IMasterLogic, IComponentHolder { byte direction; - TankLayerScan structure = new TankLayerScan(this, TContent.smeltery, TContent.lavaTank); + SmelteryScan structure = new SmelteryScan(this, TContent.smeltery, TContent.lavaTank); MultiFluidTank multitank = new MultiFluidTank(); - SmelteryComponent smeltery = new SmelteryComponent(this, this.worldObj, multitank, 800); + SmelteryComponent smeltery = new SmelteryComponent(this, structure, multitank, 800); + + int tick = 0; + + public void updateEntity () + { + tick++; + if (tick % 4 == 0) + smeltery.heatItems(); + + if (tick % 20 == 0) + { + if (!structure.isComplete()) + { + structure.checkValidStructure(); + if (structure.isComplete()) + { + smeltery.adjustSize(structure.getAirSize(), true); + multitank.setCapacity(structure.getAirSize() * (TConstruct.ingotLiquidValue * 18)); + } + } + else + { + smeltery.update(); + } + } + + if (tick == 60) + { + tick = 0; + } + } + + @Override + public void setWorldObj (World world) + { + super.setWorldObj(world); + structure.setWorld(world); + smeltery.setWorld(world); + } @Override public byte getRenderDirection () @@ -71,28 +117,18 @@ public class AdaptiveSmelteryLogic extends AdaptiveInventoryLogic implements IAc @Override public boolean getActive () { - // TODO Auto-generated method stub - return false; + return structure.isComplete(); } @Override public void setActive (boolean flag) { - // TODO Auto-generated method stub - - } - @Override - public void setNeedsUpdate () - { - // TODO Auto-generated method stub - } @Override public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) { - // TODO Auto-generated method stub return null; } @@ -105,7 +141,7 @@ public class AdaptiveSmelteryLogic extends AdaptiveInventoryLogic implements IAc @Override public List getComponents () { - ArrayList ret = new ArrayList(1); + ArrayList ret = new ArrayList(3); ret.add(structure); ret.add(multitank); ret.add(smeltery); @@ -113,9 +149,78 @@ public class AdaptiveSmelteryLogic extends AdaptiveInventoryLogic implements IAc } @Override - public void notifyChange (int x, int y, int z) + public void notifyChange (IServantLogic servant, int x, int y, int z) { - // TODO Auto-generated method stub - + + } + + @Override + public void placeBlock (EntityLivingBase entity, ItemStack itemstack) + { + structure.checkValidStructure(); + if (structure.isComplete()) + { + smeltery.adjustSize(structure.getAirSize(), true); + multitank.setCapacity(structure.getAirSize() * (TConstruct.ingotLiquidValue * 18)); + } + } + + @Override + public void removeBlock () + { + structure.cleanup(); + } + + @Override + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + + structure.readFromNBT(tags); + multitank.readFromNBT(tags); + smeltery.readFromNBT(tags); + } + + @Override + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + + structure.writeToNBT(tags); + multitank.writeToNBT(tags); + smeltery.writeToNBT(tags); + } + + public void readNetworkNBT (NBTTagCompound tags) + { + direction = tags.getByte("Direction"); + + structure.readNetworkNBT(tags); + multitank.readNetworkNBT(tags); + smeltery.readNetworkNBT(tags); + } + + public void writeNetworkNBT (NBTTagCompound tags) + { + tags.setByte("Direction", direction); + + structure.writeNetworkNBT(tags); + multitank.writeNetworkNBT(tags); + smeltery.writeNetworkNBT(tags); + } + + @Override + public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) + { + readNetworkNBT(packet.data); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + + @Override + public Packet getDescriptionPacket () + { + NBTTagCompound tag = new NBTTagCompound(); + writeNetworkNBT(tag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); } } diff --git a/src/tconstruct/blocks/logic/MultiServantLogic.java b/src/tconstruct/blocks/logic/MultiServantLogic.java index 79bb5a09..06687648 100644 --- a/src/tconstruct/blocks/logic/MultiServantLogic.java +++ b/src/tconstruct/blocks/logic/MultiServantLogic.java @@ -5,6 +5,7 @@ import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; import tconstruct.library.util.CoordTuple; import tconstruct.library.util.IMasterLogic; import tconstruct.library.util.IServantLogic; @@ -66,12 +67,13 @@ public class MultiServantLogic extends TileEntity implements IServantLogic } @Override - public boolean setPotentialMaster (IMasterLogic master, int x, int y, int z) + public boolean setPotentialMaster (IMasterLogic master, World world, int x, int y, int z) { // TODO Auto-generated method stub return true; } + @Deprecated public boolean setMaster (int x, int y, int z) { if (!hasMaster || worldObj.getBlockId(master.x, master.y, master.z) != masterID || (worldObj.getBlockMetadata(master.x, master.y, master.z) != masterMeat)) @@ -90,7 +92,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic if (hasValidMaster()) { IMasterLogic logic = (IMasterLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z); - logic.notifyChange(xCoord, yCoord, zCoord); + logic.notifyChange(this, xCoord, yCoord, zCoord); } } @@ -150,4 +152,18 @@ public class MultiServantLogic extends TileEntity implements IServantLogic readCustomNBT(packet.data); worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } + + @Override + public boolean verifyMaster (IMasterLogic master, World world, int x, int y, int z) + { + // TODO Auto-generated method stub + return false; + } + + @Override + public void invalidateMaster (IMasterLogic master, World world, int x, int y, int z) + { + hasMaster = false; + master = null; + } } diff --git a/src/tconstruct/blocks/logic/SmelteryLogic.java b/src/tconstruct/blocks/logic/SmelteryLogic.java index 275138a7..f5bf6553 100644 --- a/src/tconstruct/blocks/logic/SmelteryLogic.java +++ b/src/tconstruct/blocks/logic/SmelteryLogic.java @@ -1,6 +1,9 @@ package tconstruct.blocks.logic; -import cpw.mods.fml.common.network.PacketDispatcher; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; @@ -33,12 +36,10 @@ import tconstruct.library.util.CoordTuple; import tconstruct.library.util.IActiveLogic; import tconstruct.library.util.IFacingLogic; import tconstruct.library.util.IMasterLogic; -import tconstruct.util.PHConstruct; +import tconstruct.library.util.IServantLogic; import tconstruct.util.SmelteryDamageSource; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; +import tconstruct.util.config.PHConstruct; +import cpw.mods.fml.common.network.PacketDispatcher; /* Simple class for storing items in the block */ @@ -651,7 +652,7 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci /* Multiblock */ @Override - public void notifyChange (int x, int y, int z) + public void notifyChange (IServantLogic servant, int x, int y, int z) { checkValidPlacement(); } diff --git a/src/tconstruct/blocks/logic/TankAirLogic.java b/src/tconstruct/blocks/logic/TankAirLogic.java new file mode 100644 index 00000000..ec4e8831 --- /dev/null +++ b/src/tconstruct/blocks/logic/TankAirLogic.java @@ -0,0 +1,76 @@ +package tconstruct.blocks.logic; + +import java.util.ArrayList; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidStack; +import tconstruct.TConstruct; +import tconstruct.blocks.component.TankAirComponent; +import tconstruct.library.blocks.InventoryLogic; +import tconstruct.library.util.CoordTuple; +import tconstruct.library.util.IMasterLogic; +import tconstruct.library.util.IServantLogic; + +public class TankAirLogic extends InventoryLogic implements IServantLogic +{ + TankAirComponent multitank = new TankAirComponent(TConstruct.ingotLiquidValue * 18); + CoordTuple master; + + public TankAirLogic() + { + super(1); + } + + public void overrideFluids(ArrayList fluids) + { + multitank.overrideFluids(fluids); + } + + @Override + public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) + { + return null; //Not a gui block + } + + @Override + protected String getDefaultName () + { + return null; //Not a gui block + } + + @Override + public CoordTuple getMasterPosition () + { + return master; + } + + @Override + public void notifyMasterOfChange () + { + //Probably not useful here + } + + @Override + public boolean setPotentialMaster (IMasterLogic master, World world, int xMaster, int yMaster, int zMaster) + { + return false; //Master should be verified right after placement + } + + @Override + public boolean verifyMaster (IMasterLogic logic, World world, int xMaster, int yMaster, int zMaster) + { + if (master != null) + return false; + + master = new CoordTuple(xMaster, yMaster, zMaster); + return true; + } + + @Override + public void invalidateMaster (IMasterLogic master, World world, int xMaster, int yMaster, int zMaster) + { + world.setBlockToAir(xCoord, yCoord, zCoord); + } +} diff --git a/src/tconstruct/blocks/logic/TowerFurnaceLogic.java b/src/tconstruct/blocks/logic/TowerFurnaceLogic.java index 2683f5a4..35038ce3 100644 --- a/src/tconstruct/blocks/logic/TowerFurnaceLogic.java +++ b/src/tconstruct/blocks/logic/TowerFurnaceLogic.java @@ -3,6 +3,7 @@ package tconstruct.blocks.logic; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import tconstruct.library.blocks.AdaptiveInventoryLogic; @@ -10,79 +11,8 @@ import tconstruct.library.util.IActiveLogic; import tconstruct.library.util.IFacingLogic; import tconstruct.library.util.IMasterLogic; -public class TowerFurnaceLogic extends AdaptiveInventoryLogic implements IActiveLogic, IFacingLogic, IMasterLogic +//Not actually abstract +public abstract class TowerFurnaceLogic extends AdaptiveInventoryLogic implements IActiveLogic, IFacingLogic, IMasterLogic { - @Override - public void notifyChange (int x, int y, int z) - { - // TODO Auto-generated method stub - - } - - @Override - public byte getRenderDirection () - { - // TODO Auto-generated method stub - return 0; - } - - @Override - public ForgeDirection getForgeDirection () - { - // TODO Auto-generated method stub - return null; - } - - @Override - @Deprecated - public void setDirection (int side) - { - // TODO Auto-generated method stub - - } - - @Override - @Deprecated - public void setDirection (float yaw, float pitch, EntityLivingBase player) - { - // TODO Auto-generated method stub - - } - - @Override - public boolean getActive () - { - // TODO Auto-generated method stub - return false; - } - - @Override - public void setActive (boolean flag) - { - // TODO Auto-generated method stub - - } - - @Override - public void setNeedsUpdate () - { - // TODO Auto-generated method stub - - } - - @Override - public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) - { - // TODO Auto-generated method stub - return null; - } - - @Override - protected String getDefaultName () - { - // TODO Auto-generated method stub - return null; - } - } diff --git a/src/tconstruct/client/block/TankAirRender.java b/src/tconstruct/client/block/TankAirRender.java new file mode 100644 index 00000000..5941f2d1 --- /dev/null +++ b/src/tconstruct/client/block/TankAirRender.java @@ -0,0 +1,73 @@ +package tconstruct.client.block; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.item.Item; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; + +import tconstruct.blocks.logic.LavaTankLogic; +import tconstruct.client.TProxyClient; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class TankAirRender implements ISimpleBlockRenderingHandler +{ + public static int model = RenderingRegistry.getNextAvailableRenderId(); + + @Override + public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) + { + //No inventory block + } + + @Override + public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) + { + if (modelID == model) + { + //Liquid + LavaTankLogic logic = (LavaTankLogic) world.getBlockTileEntity(x, y, z); + if (logic.containsFluid()) + { + FluidStack liquid = logic.tank.getFluid(); + renderer.setRenderBounds(0.001, 0.001, 0.001, 0.999, logic.getFluidAmountScaled(), 0.999); + Fluid fluid = liquid.getFluid(); + if (fluid.canBePlacedInWorld()) + BlockSkinRenderHelper.renderMetadataBlock(Block.blocksList[fluid.getBlockID()], 0, x, y, z, renderer, world); + else + BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world); + + renderer.setRenderBounds(00, 0.001, 0.001, 0.999, logic.getFluidAmountScaled(), 0.999); + } + + //Block + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0 && world.getBlockId(x, y + 1, z) == 0) + { + renderer.setRenderBounds(0.1875, 0, 0.1875, 0.8125, 0.125, 0.8125); + renderer.renderStandardBlock(block, x, y + 1, z); + } + renderer.setRenderBounds(0, 0, 0, 1, 1, 1); + renderer.renderStandardBlock(block, x, y, z); + } + return true; + } + + @Override + public boolean shouldRender3DInInventory () + { + return true; + } + + @Override + public int getRenderId () + { + return model; + } +} diff --git a/src/tconstruct/common/TContent.java b/src/tconstruct/common/TContent.java index 17b1955e..35182583 100644 --- a/src/tconstruct/common/TContent.java +++ b/src/tconstruct/common/TContent.java @@ -24,7 +24,6 @@ import tconstruct.blocks.logic.*; import tconstruct.blocks.slime.*; import tconstruct.blocks.traps.*; import tconstruct.client.StepSoundSlime; -import tconstruct.compat.mystcraft.MystImcHandler; import tconstruct.entity.*; import tconstruct.entity.projectile.*; import tconstruct.items.*; @@ -38,6 +37,8 @@ import tconstruct.library.tools.ToolCore; import tconstruct.library.util.IPattern; import tconstruct.modifiers.*; import tconstruct.util.*; +import tconstruct.util.config.MystImcHandler; +import tconstruct.util.config.PHConstruct; public class TContent implements IFuelHandler { @@ -383,6 +384,7 @@ public class TContent implements IFuelHandler smeltery = new SmelteryBlock(PHConstruct.smeltery).setUnlocalizedName("Smeltery"); GameRegistry.registerBlock(smeltery, SmelteryItemBlock.class, "Smeltery"); GameRegistry.registerTileEntity(SmelteryLogic.class, "TConstruct.Smeltery"); + //GameRegistry.registerTileEntity(AdaptiveSmelteryLogic.class, "TConstruct.Smeltery"); GameRegistry.registerTileEntity(SmelteryDrainLogic.class, "TConstruct.SmelteryDrain"); GameRegistry.registerTileEntity(MultiServantLogic.class, "TConstruct.Servants"); diff --git a/src/tconstruct/compat/BOP.java b/src/tconstruct/compat/BOP.java deleted file mode 100644 index 3c316054..00000000 --- a/src/tconstruct/compat/BOP.java +++ /dev/null @@ -1,36 +0,0 @@ -package tconstruct.compat; - -import java.io.File; -import java.io.IOException; -import net.minecraftforge.common.Configuration; - -public class BOP { - public static void initProps (File location) - { - /* Here we will set up the config file for the mod - * First: Create a folder inside the config folder - * Second: Create the actual config file - * Note: Configs are a pain, but absolutely necessary for every mod. - */ - //File file = new File(TConstruct.proxy.getLocation() + "/config"); - //file.mkdir(); - //File newFile = new File(TConstruct.proxy.getLocation() + "/config/TinkersWorkshop.txt"); - - File newFile = new File(location + "/biomesoplenty/ids.cfg"); - if( newFile.exists()){ - - /* [Forge] Configuration class, used as config method */ - Configuration config = new Configuration(newFile); - - /* Load the configuration file */ - config.load(); - - pldimid = config.get("dimension settings", "Promised Land Dimension ID", -200).getInt(); - System.out.println("[TConstruct]PL Dim ID: " + pldimid); - } - else { - pldimid = -100; - } - } - public static int pldimid; -} diff --git a/src/tconstruct/compat/Tforest.java b/src/tconstruct/compat/Tforest.java deleted file mode 100644 index fb7d6d75..00000000 --- a/src/tconstruct/compat/Tforest.java +++ /dev/null @@ -1,36 +0,0 @@ -package tconstruct.compat; - -import java.io.File; -import java.io.IOException; -import net.minecraftforge.common.Configuration; - -public class Tforest { - public static void initProps (File location) - { - /* Here we will set up the config file for the mod - * First: Create a folder inside the config folder - * Second: Create the actual config file - * Note: Configs are a pain, but absolutely necessary for every mod. - */ - //File file = new File(TConstruct.proxy.getLocation() + "/config"); - //file.mkdir(); - //File newFile = new File(TConstruct.proxy.getLocation() + "/config/TinkersWorkshop.txt"); - - File newFile = new File(location + "/TwilightForest.cfg"); - if( newFile.exists()){ - - /* [Forge] Configuration class, used as config method */ - Configuration config = new Configuration(newFile); - - /* Load the configuration file */ - config.load(); - - tfdimid = config.get("dimension", "dimensionID", -100).getInt(); - System.out.println("[TConstruct]TF Dim ID: " + tfdimid); - } - else { - tfdimid = -100; - } - } - public static int tfdimid; -} diff --git a/src/tconstruct/compat/dimensions/dimblacklist.java b/src/tconstruct/compat/dimensions/dimblacklist.java deleted file mode 100644 index 94e9065f..00000000 --- a/src/tconstruct/compat/dimensions/dimblacklist.java +++ /dev/null @@ -1,51 +0,0 @@ -package tconstruct.compat.dimensions; - -import java.util.ArrayList; - -import tconstruct.compat.BOP; -import tconstruct.compat.Tforest; -import tconstruct.util.PHConstruct; - -public class dimblacklist { -public static ArrayList blacklist = new ArrayList(); -public static ArrayList nopool = new ArrayList(); -public static void getbaddimensions(){ - blacklist.add(1); - if (Tforest.tfdimid != -100){ - blacklist.add(Tforest.tfdimid); - } - if(PHConstruct.cfgDimBlackList.length > 0){ - for (int numdim = 0; numdim< PHConstruct.cfgDimBlackList.length; numdim ++){ - blacklist.add(PHConstruct.cfgDimBlackList[numdim]); - } - } - if (BOP.pldimid != -100){ - nopool.add(BOP.pldimid); - } -} -public static boolean isDimInBlacklist(int dim){ - if (dim<0) - return false; - if (dim==0) - return PHConstruct.slimeIslGenDim0; - if(PHConstruct.slimeIslGenDim0Only && dim != 0){ - return false; - } - for (int len = 0;len< blacklist.size(); len++){ - if (blacklist.get(len) == dim) - return false; - //System.out.println("[TConstruct]diminblist +" + blacklist.get(len)); - } - return true; - -} -public static boolean isDimNoPool(int dim){ - for (int len = 0;len< nopool.size(); len++){ - if (nopool.get(len) == dim) - //System.out.println("[TConstruct]DimNoPool "+ nopool.get(len)); - return true; - } - return false; - -} -} diff --git a/src/tconstruct/items/tools/Cleaver.java b/src/tconstruct/items/tools/Cleaver.java index 7d0dc27f..a80b7c71 100644 --- a/src/tconstruct/items/tools/Cleaver.java +++ b/src/tconstruct/items/tools/Cleaver.java @@ -3,7 +3,7 @@ package tconstruct.items.tools; import tconstruct.common.TContent; import tconstruct.library.tools.AbilityHelper; import tconstruct.library.tools.Weapon; -import tconstruct.util.PHConstruct; +import tconstruct.util.config.PHConstruct; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; diff --git a/src/tconstruct/items/tools/Hatchet.java b/src/tconstruct/items/tools/Hatchet.java index 53839bdb..32a10158 100644 --- a/src/tconstruct/items/tools/Hatchet.java +++ b/src/tconstruct/items/tools/Hatchet.java @@ -3,7 +3,7 @@ package tconstruct.items.tools; import tconstruct.common.TContent; import tconstruct.library.tools.AbilityHelper; import tconstruct.library.tools.HarvestTool; -import tconstruct.util.PHConstruct; +import tconstruct.util.config.PHConstruct; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; diff --git a/src/tconstruct/items/tools/Mattock.java b/src/tconstruct/items/tools/Mattock.java index 624ed60f..3c1b3359 100644 --- a/src/tconstruct/items/tools/Mattock.java +++ b/src/tconstruct/items/tools/Mattock.java @@ -12,7 +12,7 @@ import tconstruct.common.TContent; import tconstruct.library.crafting.ToolBuilder; import tconstruct.library.tools.AbilityHelper; import tconstruct.library.tools.DualHarvestTool; -import tconstruct.util.PHConstruct; +import tconstruct.util.config.PHConstruct; public class Mattock extends DualHarvestTool { diff --git a/src/tconstruct/library/blocks/AdaptiveInventoryLogic.java b/src/tconstruct/library/blocks/AdaptiveInventoryLogic.java index 90e3ffca..c57ad0b4 100644 --- a/src/tconstruct/library/blocks/AdaptiveInventoryLogic.java +++ b/src/tconstruct/library/blocks/AdaptiveInventoryLogic.java @@ -6,6 +6,7 @@ import java.util.Iterator; import java.util.Random; import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -29,7 +30,6 @@ public abstract class AdaptiveInventoryLogic extends InventoryLogic implements I { if (size != inventorySize || forceAdjust) { - setNeedsUpdate(); inventorySize = size; ItemStack[] tempInv = inventory; @@ -102,8 +102,6 @@ public abstract class AdaptiveInventoryLogic extends InventoryLogic implements I } } } - - public abstract void setNeedsUpdate(); public int getTossDirection () { diff --git a/src/tconstruct/library/blocks/InventoryBlock.java b/src/tconstruct/library/blocks/InventoryBlock.java index 77d33857..ad0b50ad 100644 --- a/src/tconstruct/library/blocks/InventoryBlock.java +++ b/src/tconstruct/library/blocks/InventoryBlock.java @@ -63,13 +63,14 @@ public abstract class InventoryBlock extends BlockContainer /* Inventory */ @Override - public void breakBlock (World par1World, int x, int y, int z, int par5, int meta) + public void breakBlock (World par1World, int x, int y, int z, int blockID, int meta) { TileEntity te = par1World.getBlockTileEntity(x, y, z); if (te != null && te instanceof InventoryLogic) { InventoryLogic logic = (InventoryLogic) te; + logic.removeBlock(); for (int iter = 0; iter < logic.getSizeInventory(); ++iter) { ItemStack stack = logic.getStackInSlot(iter); @@ -108,7 +109,7 @@ public abstract class InventoryBlock extends BlockContainer } } - super.breakBlock(par1World, x, y, z, par5, meta); + super.breakBlock(par1World, x, y, z, blockID, meta); } /* Placement */ @@ -145,9 +146,14 @@ public abstract class InventoryBlock extends BlockContainer } } - if (stack.hasDisplayName()) + if (logic instanceof InventoryLogic) { - ((InventoryLogic) world.getBlockTileEntity(x, y, z)).setInvName(stack.getDisplayName()); + InventoryLogic inv = (InventoryLogic) logic; + inv.placeBlock(entityliving, stack); + if (stack.hasDisplayName()) + { + inv.setInvName(stack.getDisplayName()); + } } } diff --git a/src/tconstruct/library/blocks/InventoryLogic.java b/src/tconstruct/library/blocks/InventoryLogic.java index 6e9533db..c0221945 100644 --- a/src/tconstruct/library/blocks/InventoryLogic.java +++ b/src/tconstruct/library/blocks/InventoryLogic.java @@ -1,5 +1,6 @@ package tconstruct.library.blocks; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; @@ -184,4 +185,14 @@ public abstract class InventoryLogic extends TileEntity implements IInventory } return false; } + + public void placeBlock (EntityLivingBase entity, ItemStack stack) + { + + } + + public void removeBlock() + { + + } } diff --git a/src/tconstruct/library/component/LogicComponent.java b/src/tconstruct/library/component/LogicComponent.java index 43cdac1f..7e070435 100644 --- a/src/tconstruct/library/component/LogicComponent.java +++ b/src/tconstruct/library/component/LogicComponent.java @@ -1,6 +1,34 @@ package tconstruct.library.component; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + public class LogicComponent { + protected World world; + public void setWorld(World world) + { + this.world = world; + } + + public void readFromNBT (NBTTagCompound tags) + { + + } + + public void writeToNBT (NBTTagCompound tags) + { + + } + + public void readNetworkNBT (NBTTagCompound tags) + { + + } + + public void writeNetworkNBT (NBTTagCompound tags) + { + + } } \ No newline at end of file diff --git a/src/tconstruct/library/component/MultiFluidTank.java b/src/tconstruct/library/component/MultiFluidTank.java index b520ca7a..8de66893 100644 --- a/src/tconstruct/library/component/MultiFluidTank.java +++ b/src/tconstruct/library/component/MultiFluidTank.java @@ -3,23 +3,51 @@ package tconstruct.library.component; import java.util.ArrayList; import tconstruct.library.crafting.Smeltery; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidTank; public class MultiFluidTank extends LogicComponent implements IFluidTank { - public ArrayList moltenMetal = new ArrayList(); - int maxLiquid; - int currentLiquid; - + public ArrayList fluidlist = new ArrayList(); + protected int maxLiquid; + protected int currentLiquid; + + public MultiFluidTank() + { + } + + public MultiFluidTank(int max) + { + maxLiquid = max; + } + + public void setCapacity (int i) + { + maxLiquid = i; + } + + @Override + public int getCapacity () + { + return maxLiquid; + } + + @Override + public int getFluidAmount () + { + return currentLiquid; + } + @Override public FluidStack drain (int maxDrain, boolean doDrain) { - if (moltenMetal.size() == 0) + if (fluidlist.size() == 0) return null; - FluidStack liquid = moltenMetal.get(0); + FluidStack liquid = fluidlist.get(0); if (liquid != null) { if (liquid.amount - maxDrain <= 0) @@ -27,7 +55,7 @@ public class MultiFluidTank extends LogicComponent implements IFluidTank FluidStack liq = liquid.copy(); if (doDrain) { - moltenMetal.remove(liquid); + fluidlist.remove(liquid); currentLiquid = 0; } return liq; @@ -61,7 +89,7 @@ public class MultiFluidTank extends LogicComponent implements IFluidTank { if (addFluidToTank(resource, false)) { - ArrayList alloys = Smeltery.mixMetals(moltenMetal); + ArrayList alloys = Smeltery.mixMetals(fluidlist); for (int al = 0; al < alloys.size(); al++) { FluidStack liquid = (FluidStack) alloys.get(al); @@ -75,11 +103,11 @@ public class MultiFluidTank extends LogicComponent implements IFluidTank return 0; } - boolean addFluidToTank (FluidStack liquid, boolean first) + public boolean addFluidToTank (FluidStack liquid, boolean first) { - if (moltenMetal.size() == 0) + if (fluidlist.size() == 0) { - moltenMetal.add(liquid.copy()); + fluidlist.add(liquid.copy()); currentLiquid += liquid.amount; return true; } @@ -90,9 +118,9 @@ public class MultiFluidTank extends LogicComponent implements IFluidTank currentLiquid += liquid.amount; boolean added = false; - for (int i = 0; i < moltenMetal.size(); i++) + for (int i = 0; i < fluidlist.size(); i++) { - FluidStack l = moltenMetal.get(i); + FluidStack l = fluidlist.get(i); if (l.isFluidEqual(liquid)) { l.amount += liquid.amount; @@ -100,16 +128,16 @@ public class MultiFluidTank extends LogicComponent implements IFluidTank } if (l.amount <= 0) { - moltenMetal.remove(l); + fluidlist.remove(l); i--; } } if (!added) { if (first) - moltenMetal.add(0, liquid.copy()); + fluidlist.add(0, liquid.copy()); else - moltenMetal.add(liquid.copy()); + fluidlist.add(liquid.copy()); } return true; } @@ -118,9 +146,9 @@ public class MultiFluidTank extends LogicComponent implements IFluidTank @Override public FluidStack getFluid () { - if (moltenMetal.size() == 0) + if (fluidlist.size() == 0) return null; - return moltenMetal.get(0); + return fluidlist.get(0); } @Override @@ -131,26 +159,41 @@ public class MultiFluidTank extends LogicComponent implements IFluidTank public FluidTankInfo[] getMultiTankInfo () { - FluidTankInfo[] info = new FluidTankInfo[moltenMetal.size() + 1]; - for (int i = 0; i < moltenMetal.size(); i++) + FluidTankInfo[] info = new FluidTankInfo[fluidlist.size() + 1]; + for (int i = 0; i < fluidlist.size(); i++) { - FluidStack fluid = moltenMetal.get(i); + FluidStack fluid = fluidlist.get(i); info[i] = new FluidTankInfo(fluid.copy(), fluid.amount); } - info[moltenMetal.size()] = new FluidTankInfo(null, maxLiquid - currentLiquid); + info[fluidlist.size()] = new FluidTankInfo(null, maxLiquid - currentLiquid); return info; } @Override - public int getFluidAmount () + public void readFromNBT (NBTTagCompound tags) { - return currentLiquid; + NBTTagList liquidTag = tags.getTagList("Liquids"); + fluidlist.clear(); + + for (int iter = 0; iter < liquidTag.tagCount(); iter++) + { + NBTTagCompound nbt = (NBTTagCompound) liquidTag.tagAt(iter); + FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbt); + fluidlist.add(fluid); + } } @Override - public int getCapacity () + public void writeToNBT (NBTTagCompound tags) { - return maxLiquid; - } + NBTTagList taglist = new NBTTagList(); + for (FluidStack liquid : fluidlist) + { + NBTTagCompound nbt = new NBTTagCompound(); + liquid.writeToNBT(nbt); + taglist.appendTag(nbt); + } + tags.setTag("Liquids", taglist); + } } diff --git a/src/tconstruct/library/component/SmelteryComponent.java b/src/tconstruct/library/component/SmelteryComponent.java deleted file mode 100644 index 7262ec65..00000000 --- a/src/tconstruct/library/component/SmelteryComponent.java +++ /dev/null @@ -1,125 +0,0 @@ -package tconstruct.library.component; - -import java.util.ArrayList; - -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.fluids.FluidStack; -import tconstruct.library.crafting.Smeltery; - -public class SmelteryComponent extends LogicComponent -{ - World world; - IInventory master; - MultiFluidTank multitank; - - int internalTemp; - public int useTime; - public int fuelGague; - public int fuelAmount; - boolean inUse; - - public int[] activeTemps; - public int[] meltingTemps; - - public SmelteryComponent(IInventory inventory, World world, MultiFluidTank multitank, int maxTemp) - { - master = inventory; - this.world = world; - this.multitank = multitank; - internalTemp = maxTemp; - } - - public void adjustSize (int size, boolean forceAdjust) - { - if (size != activeTemps.length || forceAdjust) - { - int[] tempActive = activeTemps; - activeTemps = new int[size]; - int activeLength = tempActive.length > activeTemps.length ? activeTemps.length : tempActive.length; - System.arraycopy(tempActive, 0, activeTemps, 0, activeLength); - - int[] tempMelting = meltingTemps; - meltingTemps = new int[size]; - int meltingLength = tempMelting.length > meltingTemps.length ? meltingTemps.length : tempMelting.length; - System.arraycopy(tempMelting, 0, meltingTemps, 0, meltingLength); - - if (activeTemps.length > 0 && activeTemps.length > tempActive.length) - { - for (int i = tempActive.length; i < activeTemps.length; i++) - { - activeTemps[i] = 20; - meltingTemps[i] = 20; - } - } - } - } - - void heatItems () - { - if (useTime > 0) - { - boolean hasUse = false; - for (int i = 0; i < meltingTemps.length; i++) - { - ItemStack slot = master.getStackInSlot(i); - if (meltingTemps[i] > 20 && slot != null) - { - hasUse = true; - if (activeTemps[i] < internalTemp && activeTemps[i] < meltingTemps[i]) - { - activeTemps[i] += 1; - } - else if (activeTemps[i] >= meltingTemps[i]) - { - if (!world.isRemote) - { - FluidStack result = getResultFor(slot); - if (result != null) - { - if (multitank.addFluidToTank(result, false)) - { - master.setInventorySlotContents(i, null); - activeTemps[i] = 20; - ArrayList alloys = Smeltery.mixMetals(multitank.moltenMetal); - for (int al = 0; al < alloys.size(); al++) - { - FluidStack liquid = (FluidStack) alloys.get(al); - multitank.addFluidToTank(liquid, true); - } - master.onInventoryChanged(); - } - } - } - } - - } - - else - activeTemps[i] = 20; - } - inUse = hasUse; - } - } - - public FluidStack getResultFor (ItemStack stack) - { - return Smeltery.instance.getSmelteryResult(stack); - } - - public int getInternalTemperature () - { - return internalTemp; - } - - public int getTempForSlot (int slot) - { - return activeTemps[slot]; - } - - public int getMeltingPointForSlot (int slot) - { - return meltingTemps[slot]; - } -} diff --git a/src/tconstruct/library/component/TankLayerScan.java b/src/tconstruct/library/component/TankLayerScan.java index feff6201..3f83e377 100644 --- a/src/tconstruct/library/component/TankLayerScan.java +++ b/src/tconstruct/library/component/TankLayerScan.java @@ -1,12 +1,11 @@ package tconstruct.library.component; import java.util.ArrayList; -import java.util.HashSet; import java.util.Iterator; +import java.util.TreeSet; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; import tconstruct.library.util.CoordTuple; import tconstruct.library.util.IFacingLogic; import tconstruct.library.util.IMasterLogic; @@ -14,29 +13,30 @@ import tconstruct.library.util.IServantLogic; public class TankLayerScan extends LogicComponent { - TileEntity master; - IMasterLogic imaster; - World world; - Block[] scanBlocks; + protected TileEntity master; + protected IMasterLogic imaster; + protected Block[] scanBlocks; - public boolean completeStructure; + protected boolean completeStructure; - int bricks = 0; - int airBlocks = 0; - HashSet tempBlockCoords = new HashSet(); - HashSet tempAirCoords = new HashSet(); + protected int bricks = 0; + protected int airBlocks = 0; + protected TreeSet tempBlockCoords = new TreeSet(); + protected TreeSet tempAirCoords = new TreeSet(); - public HashSet blockCoords = new HashSet(); - public HashSet airCoords = new HashSet(); - ArrayList validAirCoords = new ArrayList(); - CoordTuple returnStone; + public TreeSet blockCoords = new TreeSet(); + public TreeSet airCoords = new TreeSet(); + protected ArrayList validAirCoords = new ArrayList(); + protected CoordTuple returnStone; + + private boolean debug = false; - public TankLayerScan(TileEntity te, Block... id) + public TankLayerScan(TileEntity te, Block... ids) { assert te instanceof IMasterLogic : "TileEntity must be an instance of IMasterLogic"; master = te; imaster = (IMasterLogic) te; - scanBlocks = id; + scanBlocks = ids; validAirCoords.add(new int[] { 1, 0 }); validAirCoords.add(new int[] { -1, 0 }); validAirCoords.add(new int[] { 0, 1 }); @@ -99,14 +99,14 @@ public class TankLayerScan extends LogicComponent xPos = -1; break; } - if (!world.isRemote) + if (!world.isRemote && debug) System.out.println("Bricks in recursion: " + blockCoords.size()); blockCoords.clear(); bricks = 0; //Does the actual adding of blocks in the ring boolean sealed = floodTest(master.xCoord + xPos, master.yCoord, master.zCoord + zPos); - if (!world.isRemote) + if (!world.isRemote && debug) { System.out.println("Air in ring: " + airBlocks); System.out.println("Bricks in ring: " + bricks); @@ -114,15 +114,15 @@ public class TankLayerScan extends LogicComponent if (sealed) { - tempAirCoords = new HashSet(airCoords); - tempBlockCoords = new HashSet(blockCoords); + tempAirCoords = new TreeSet(airCoords); + tempBlockCoords = new TreeSet(blockCoords); if (recurseStructureDown(master.yCoord - 1)) { completeStructure = true; recurseStructureUp(master.yCoord + 1); - if (!world.isRemote) + if (!world.isRemote && debug) { System.out.println("Air in structure: " + airCoords.size()); System.out.println("Bricks in structure: " + blockCoords.size()); @@ -130,7 +130,25 @@ public class TankLayerScan extends LogicComponent } } } + + if (completeStructure) + { + + } + else + { + + } + } + public boolean isComplete () + { + return completeStructure; + } + + public int getAirSize() + { + return airBlocks; } private byte getDirection () @@ -152,7 +170,7 @@ public class TankLayerScan extends LogicComponent protected boolean checkServant (int x, int y, int z) { Block block = Block.blocksList[world.getBlockId(x, y, z)]; - if (block == null || block.isAirBlock(world, x, y, z)) + if (block == null || block.isAirBlock(world, x, y, z) || !isValidBlock(x, y, z)) return false; if (!block.hasTileEntity(world.getBlockMetadata(x, y, z))) @@ -160,14 +178,14 @@ public class TankLayerScan extends LogicComponent TileEntity be = world.getBlockTileEntity(x, y, z); if (be instanceof IServantLogic) - return ((IServantLogic) be).setPotentialMaster(this.imaster, x, y, z); + return ((IServantLogic) be).setPotentialMaster(this.imaster, this.world, x, y, z); return false; } protected boolean initialRecurseLayer (int x, int y, int z) { - if (bricks >= 4095) + if (bricks > 4000) return false; CoordTuple keystone = new CoordTuple(x, y, z); @@ -210,7 +228,7 @@ public class TankLayerScan extends LogicComponent protected boolean floodTest (int x, int y, int z) { - if (airBlocks >= 4095) + if (airBlocks > 4000) return false; for (int[] offset : validAirCoords) @@ -220,7 +238,6 @@ public class TankLayerScan extends LogicComponent { if (checkAir(x + offset[0], y, z + offset[1])) { - airCoords.add(coord); addAirBlock(coord.x, y, coord.z); floodTest(x + offset[0], y, z + offset[1]); } @@ -237,100 +254,19 @@ public class TankLayerScan extends LogicComponent public boolean recurseStructureDown (int y) { Iterator i = tempAirCoords.iterator(); - CoordTuple coord = (CoordTuple) i.next(); - if (checkAir(coord.x, y, coord.z)) + if (i.hasNext()) { - boolean valid = true; - - //Air blocks - while (i.hasNext()) + CoordTuple coord = (CoordTuple) i.next(); + if (checkAir(coord.x, y, coord.z)) { - coord = (CoordTuple) i.next(); - if (checkAir(coord.x, y, coord.z)) - { - airCoords.add(new CoordTuple(coord.x, y, coord.z)); - addAirBlock(coord.x, y, coord.z); - } - else - { - valid = false; - break; - } - } + boolean valid = true; - //Bricks - i = tempBlockCoords.iterator(); - while (i.hasNext()) - { - coord = (CoordTuple) i.next(); - if (checkServant(coord.x, y, coord.z)) - blockCoords.add(new CoordTuple(coord.x, y, coord.z)); - - else - { - valid = false; - break; - } - } - - if (valid) - return recurseStructureDown(y - 1); - } - else if (checkServant(coord.x, y, coord.z)) - { - //Bottom floor. All blocks, please vacate the elevator - boolean valid = true; - while (i.hasNext()) - { - coord = (CoordTuple) i.next(); - - if (checkServant(coord.x, y, coord.z)) - blockCoords.add(new CoordTuple(coord.x, y, coord.z)); - - else - { - valid = false; - break; - } - } - return valid; - } - - return false; - } - - public void recurseStructureUp (int y) - { - Iterator i = tempBlockCoords.iterator(); - CoordTuple coord = (CoordTuple) i.next(); - if (checkServant(coord.x, y, coord.z)) - { - boolean valid = true; - - //Bricks - while (i.hasNext()) - { - coord = (CoordTuple) i.next(); - if (checkServant(coord.x, y, coord.z)) - blockCoords.add(new CoordTuple(coord.x, y, coord.z)); - - else - { - valid = false; - break; - } - } - - //Air blocks - if (valid) - { - i = tempAirCoords.iterator(); + //Air blocks while (i.hasNext()) { coord = (CoordTuple) i.next(); if (checkAir(coord.x, y, coord.z)) { - airCoords.add(new CoordTuple(coord.x, y, coord.z)); addAirBlock(coord.x, y, coord.z); } else @@ -339,16 +275,114 @@ public class TankLayerScan extends LogicComponent break; } } - } - if (valid) - recurseStructureUp(y + 1); + //Bricks + i = tempBlockCoords.iterator(); + while (i.hasNext()) + { + coord = (CoordTuple) i.next(); + if (checkServant(coord.x, y, coord.z)) + blockCoords.add(new CoordTuple(coord.x, y, coord.z)); + + else + { + valid = false; + break; + } + } + + if (valid) + return recurseStructureDown(y - 1); + } + else if (checkServant(coord.x, y, coord.z)) + { + //Bottom floor. All blocks, please vacate the elevator + boolean valid = true; + while (i.hasNext()) + { + coord = (CoordTuple) i.next(); + + if (checkServant(coord.x, y, coord.z)) + blockCoords.add(new CoordTuple(coord.x, y, coord.z)); + + else + { + valid = false; + break; + } + } + return valid; + } + } + + return false; + } + + public void recurseStructureUp (int y) + { + Iterator i = tempBlockCoords.iterator(); + if (i.hasNext()) + { + CoordTuple coord = (CoordTuple) i.next(); + if (checkServant(coord.x, y, coord.z)) + { + boolean valid = true; + + //Bricks + while (i.hasNext()) + { + coord = (CoordTuple) i.next(); + if (checkServant(coord.x, y, coord.z)) + blockCoords.add(new CoordTuple(coord.x, y, coord.z)); + + else + { + valid = false; + break; + } + } + + //Air blocks + if (valid) + { + i = tempAirCoords.iterator(); + while (i.hasNext()) + { + coord = (CoordTuple) i.next(); + if (checkAir(coord.x, y, coord.z)) + { + addAirBlock(coord.x, y, coord.z); + } + else + { + valid = false; + break; + } + } + } + + if (valid) + recurseStructureUp(y + 1); + } } } protected void addAirBlock (int x, int y, int z) { airBlocks++; - //world.setBlock(x + offset[0], y, z + offset[1], Block.leaves.blockID); + airCoords.add(new CoordTuple(x, y, z)); + } + + /** Do any necessary cleanup here. Remove air blocks, invalidate servants, etc */ + public void cleanup () + { + Iterator i = blockCoords.iterator(); + while (i.hasNext()) + { + CoordTuple coord = (CoordTuple) i.next(); + IServantLogic servant = (IServantLogic) world.getBlockTileEntity(coord.x, coord.y, coord.z); + if (servant != null) + servant.invalidateMaster(imaster, world, master.xCoord, master.yCoord, master.zCoord); + } } } diff --git a/src/tconstruct/library/tools/ToolCore.java b/src/tconstruct/library/tools/ToolCore.java index 537fe00a..619856e9 100644 --- a/src/tconstruct/library/tools/ToolCore.java +++ b/src/tconstruct/library/tools/ToolCore.java @@ -9,17 +9,12 @@ import java.util.List; import java.util.Map; import java.util.Random; -import tconstruct.library.ActiveToolMod; -import tconstruct.library.TConstructRegistry; -import tconstruct.library.crafting.ToolBuilder; - import mods.battlegear2.api.weapons.IBattlegearWeapon; import mods.battlegear2.api.weapons.OffhandAttackEvent; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -29,6 +24,12 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Icon; import net.minecraft.world.World; import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import tconstruct.library.ActiveToolMod; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.ToolBuilder; +import appeng.api.IAEItemStack; +import appeng.api.me.items.IAEChargeableItem; +import appeng.api.me.items.IStorageCell; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -58,7 +59,7 @@ import cpw.mods.fml.relauncher.SideOnly; * @see ToolMod */ -public abstract class ToolCore extends Item implements ICustomElectricItem, IBoxable, IBattlegearWeapon +public abstract class ToolCore extends Item implements ICustomElectricItem, IBoxable, IBattlegearWeapon, IStorageCell, IAEChargeableItem { protected Random random = new Random(); protected int damageVsEntity; @@ -731,6 +732,74 @@ public abstract class ToolCore extends Item implements ICustomElectricItem, IBox return used; } + /* Vanilla overrides */ + public boolean isItemTool (ItemStack par1ItemStack) + { + return false; + } + + @Override + public boolean getIsRepairable (ItemStack par1ItemStack, ItemStack par2ItemStack) + { + return false; + } + + public boolean isRepairable () + { + return false; + } + + public int getItemEnchantability () + { + return 0; + } + + public boolean isFull3D () + { + return true; + } + + @SideOnly(Side.CLIENT) + public boolean hasEffect (ItemStack par1ItemStack, int pass) + { + return false; + } + + /* Proper stack damage */ + public int getItemMaxDamageFromStack (ItemStack stack) + { + NBTTagCompound tags = stack.getTagCompound(); + if (tags == null) + { + return 0; + } + + if (tags.hasKey("charge")) + { + int charge = tags.getInteger("charge"); + if (charge > 0) + return this.getMaxCharge(stack); + } + return tags.getCompoundTag("InfiTool").getInteger("TotalDurability"); + } + + public int getItemDamageFromStackForDisplay (ItemStack stack) + { + NBTTagCompound tags = stack.getTagCompound(); + if (tags == null) + { + return 0; + } + + if (tags.hasKey("charge")) + { + int charge = tags.getInteger("charge"); + if (charge > 0) + return getMaxCharge(stack) - charge; + } + return tags.getCompoundTag("InfiTool").getInteger("Damage"); + } + /* IC2 Support * Every tool can be an electric tool if you modify it right */ @@ -743,11 +812,12 @@ public abstract class ToolCore extends Item implements ICustomElectricItem, IBox @Override public boolean canProvideEnergy (ItemStack stack) { - NBTTagCompound tags = stack.getTagCompound(); + return false; + /*NBTTagCompound tags = stack.getTagCompound(); if (!tags.hasKey("charge")) return false; - return true; + return true;*/ } @Override @@ -872,115 +942,104 @@ public abstract class ToolCore extends Item implements ICustomElectricItem, IBox return false; } - //Vanilla overrides - public boolean isItemTool (ItemStack par1ItemStack) + /* Battlegear support, IBattlegearWeapon */ + + @Override + public boolean willAllowOffhandWeapon () + { + return true; + } + + @Override + public boolean willAllowShield () + { + return true; + } + + @Override + public boolean isOffhandHandDualWeapon () + { + return true; + } + + @Override + public boolean sheatheOnBack () { return false; } @Override - public boolean getIsRepairable (ItemStack par1ItemStack, ItemStack par2ItemStack) - { - return false; - } - - public boolean isRepairable () - { - return false; - } - - public int getItemEnchantability () - { - return 0; - } - - public boolean isFull3D () + public boolean offhandAttackEntity (OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem) { return true; } - @SideOnly(Side.CLIENT) - public boolean hasEffect (ItemStack par1ItemStack, int pass) + @Override + public boolean offhandClickAir (PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) + { + return true; + } + + @Override + public boolean offhandClickBlock (PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) + { + return true; + } + + @Override + public void performPassiveEffects (Side effectiveSide, ItemStack mainhandItem, ItemStack offhandItem) + { + } + + /* Applied Energistics support, IAEChargableItem */ + @Override + public float addEnergy (ItemStack target, float energy) + { + // TODO Auto-generated method stub + return 0; + } + + @Override + public boolean isChargeable (ItemStack it) + { + // TODO Auto-generated method stub + return false; + } + + /* Applied Energistics support, IStorageCell */ + @Override + public int getBytes (ItemStack cellItem) + { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int BytePerType (ItemStack cellItem) + { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int getTotalTypes (ItemStack cellItem) + { + // TODO Auto-generated method stub + return 0; + } + + @Override + public boolean isBlackListed (ItemStack cellItem, IAEItemStack requsetedAddition) { return false; } - /* Proper stack damage */ - public int getItemMaxDamageFromStack (ItemStack stack) + @Override + public boolean storableInStorageCell () { - NBTTagCompound tags = stack.getTagCompound(); - if (tags == null) - { - return 0; - } - - if (tags.hasKey("charge")) - { - int charge = tags.getInteger("charge"); - if (charge > 0) - return this.getMaxCharge(stack); - } - return tags.getCompoundTag("InfiTool").getInteger("TotalDurability"); + // TODO Auto-generated method stub + return false; } - public int getItemDamageFromStackForDisplay (ItemStack stack) - { - NBTTagCompound tags = stack.getTagCompound(); - if (tags == null) - { - return 0; - } - - if (tags.hasKey("charge")) - { - int charge = tags.getInteger("charge"); - if (charge > 0) - return getMaxCharge(stack) - charge; - } - return tags.getCompoundTag("InfiTool").getInteger("Damage"); - } - - - @Override - public boolean willAllowOffhandWeapon() { - return true; - } - - @Override - public boolean willAllowShield() { - return true; - } - - @Override - public boolean isOffhandHandDualWeapon() { - return true; - } - - @Override - public boolean sheatheOnBack() { - return false; - } - - @Override - public boolean offhandAttackEntity(OffhandAttackEvent event, - ItemStack mainhandItem, ItemStack offhandItem) { - return true; - } - - @Override - public boolean offhandClickAir(PlayerInteractEvent event, - ItemStack mainhandItem, ItemStack offhandItem) { - return true; - } - - @Override - public boolean offhandClickBlock(PlayerInteractEvent event, - ItemStack mainhandItem, ItemStack offhandItem) { - return true; - } - - @Override - public void performPassiveEffects(Side effectiveSide, - ItemStack mainhandItem, ItemStack offhandItem) { - } + //Start new methods! } diff --git a/src/tconstruct/library/util/CoordTuple.java b/src/tconstruct/library/util/CoordTuple.java index 58af7b71..2d79b0be 100644 --- a/src/tconstruct/library/util/CoordTuple.java +++ b/src/tconstruct/library/util/CoordTuple.java @@ -1,6 +1,6 @@ package tconstruct.library.util; -public class CoordTuple +public class CoordTuple implements Comparable { public final int x; public final int y; @@ -51,4 +51,26 @@ public class CoordTuple { return "X: " + x + ", Y: " + y + ", Z: " + z; } + + @Override + public int compareTo (Object o) + { + if (o == null) + throw new NullPointerException("Object cannot be null"); + + CoordTuple coord = (CoordTuple) o; + if (coord.equals(this)) + return 0; + + if (coord.y != y) + return y - coord.y; + + if (coord.x != x) + return x - coord.x; + + if (coord.z != z) + return z - coord.z; + + return 0; + } } diff --git a/src/tconstruct/library/util/IMasterLogic.java b/src/tconstruct/library/util/IMasterLogic.java index e6421367..2ad5d218 100644 --- a/src/tconstruct/library/util/IMasterLogic.java +++ b/src/tconstruct/library/util/IMasterLogic.java @@ -8,5 +8,5 @@ public interface IMasterLogic * @param y Servant Y * @param z Servant Z */ - public void notifyChange (int x, int y, int z); + public void notifyChange (IServantLogic servant, int x, int y, int z); } diff --git a/src/tconstruct/library/util/IServantLogic.java b/src/tconstruct/library/util/IServantLogic.java index 5aa0cb2e..9bd6d0a0 100644 --- a/src/tconstruct/library/util/IServantLogic.java +++ b/src/tconstruct/library/util/IServantLogic.java @@ -1,5 +1,7 @@ package tconstruct.library.util; +import net.minecraft.world.World; + public interface IServantLogic { public CoordTuple getMasterPosition (); @@ -16,7 +18,7 @@ public interface IServantLogic * @return whether the servant can be tied to this master */ - public boolean setPotentialMaster(IMasterLogic master, int x, int y, int z); + public boolean setPotentialMaster(IMasterLogic master, World world, int xMaster, int yMaster, int zMaster); /** Used to set and verify that this is the block's master * @@ -27,9 +29,15 @@ public interface IServantLogic * @return Is this block tied to this master? */ - public boolean verifyMaster (IMasterLogic master, int x, int y, int z); - - /* Deprecated in favor of setPotentialMaster and verifyMaster */ - @Deprecated - public boolean setMaster (int x, int y, int z); + public boolean verifyMaster (IMasterLogic master, World world, int xMaster, int yMaster, int zMaster); + + /** Exactly what it says on the tin + * + * @param master + * @param x xCoord of master + * @param y yCoord of master + * @param z zCoord of master + */ + + public void invalidateMaster(IMasterLogic master, World world, int xMaster, int yMaster, int zMaster); } diff --git a/src/tconstruct/modifiers/ModDurability.java b/src/tconstruct/modifiers/ModDurability.java index cdd5003e..48c7824e 100644 --- a/src/tconstruct/modifiers/ModDurability.java +++ b/src/tconstruct/modifiers/ModDurability.java @@ -3,7 +3,7 @@ package tconstruct.modifiers; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import tconstruct.library.tools.ToolMod; -import tconstruct.util.PHConstruct; +import tconstruct.util.config.PHConstruct; /* Adds an integer NBTTag */ diff --git a/src/tconstruct/modifiers/TActiveOmniMod.java b/src/tconstruct/modifiers/TActiveOmniMod.java index 01810b6f..798ad874 100644 --- a/src/tconstruct/modifiers/TActiveOmniMod.java +++ b/src/tconstruct/modifiers/TActiveOmniMod.java @@ -8,7 +8,7 @@ import tconstruct.common.TContent; import tconstruct.library.ActiveToolMod; import tconstruct.library.tools.AbilityHelper; import tconstruct.library.tools.ToolCore; -import tconstruct.util.PHConstruct; +import tconstruct.util.config.PHConstruct; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; diff --git a/src/tconstruct/util/TEventHandler.java b/src/tconstruct/util/TEventHandler.java index 38c6b416..df3cf44d 100644 --- a/src/tconstruct/util/TEventHandler.java +++ b/src/tconstruct/util/TEventHandler.java @@ -40,6 +40,7 @@ import tconstruct.library.event.PartBuilderEvent; import tconstruct.library.event.ToolCraftEvent; import tconstruct.library.tools.*; import tconstruct.modifiers.ModAttack; +import tconstruct.util.config.PHConstruct; import tconstruct.util.player.TPlayerStats; import java.util.ArrayList; diff --git a/src/tconstruct/util/config/BOPConfig.java b/src/tconstruct/util/config/BOPConfig.java new file mode 100644 index 00000000..69de3591 --- /dev/null +++ b/src/tconstruct/util/config/BOPConfig.java @@ -0,0 +1,37 @@ +package tconstruct.util.config; + +import java.io.File; +import java.io.IOException; +import net.minecraftforge.common.Configuration; + +public class BOPConfig +{ + public static void initProps (File location) + { + /* Here we will set up the config file for the mod + * First: Create a folder inside the config folder + * Second: Create the actual config file + * Note: Configs are a pain, but absolutely necessary for every mod. + */ + + File newFile = new File(location + "/biomesoplenty/ids.cfg"); + if (newFile.exists()) + { + + /* [Forge] Configuration class, used as config method */ + Configuration config = new Configuration(newFile); + + /* Load the configuration file */ + config.load(); + + promisedLandDimensionID = config.get("dimension settings", "Promised Land Dimension ID", -200).getInt(); + System.out.println("[TConstruct]PL Dim ID: " + promisedLandDimensionID); + } + else + { + promisedLandDimensionID = -100; + } + } + + public static int promisedLandDimensionID; +} diff --git a/src/tconstruct/util/config/DimensionBlacklist.java b/src/tconstruct/util/config/DimensionBlacklist.java new file mode 100644 index 00000000..7f657c73 --- /dev/null +++ b/src/tconstruct/util/config/DimensionBlacklist.java @@ -0,0 +1,62 @@ +package tconstruct.util.config; + +import java.util.ArrayList; + + +public class DimensionBlacklist +{ + public static ArrayList blacklist = new ArrayList(); + public static ArrayList nopool = new ArrayList(); + + public static void getbaddimensions () + { + blacklist.add(1); + if (TwilightForestConfig.twilightForestDimensionID != -100) + { + blacklist.add(TwilightForestConfig.twilightForestDimensionID); + } + if (PHConstruct.cfgDimBlackList.length > 0) + { + for (int numdim = 0; numdim < PHConstruct.cfgDimBlackList.length; numdim++) + { + blacklist.add(PHConstruct.cfgDimBlackList[numdim]); + } + } + if (BOPConfig.promisedLandDimensionID != -100) + { + nopool.add(BOPConfig.promisedLandDimensionID); + } + } + + public static boolean isDimInBlacklist (int dim) + { + if (dim < 0) + return false; + if (dim == 0) + return PHConstruct.slimeIslGenDim0; + if (PHConstruct.slimeIslGenDim0Only && dim != 0) + { + return false; + } + for (int len = 0; len < blacklist.size(); len++) + { + if (blacklist.get(len) == dim) + return false; + //System.out.println("[TConstruct]diminblist +" + blacklist.get(len)); + } + return true; + + } + + public static boolean isDimNoPool (int dim) + { + for (int len = 0; len < nopool.size(); len++) + { + if (nopool.get(len) == dim) + //System.out.println("[TConstruct]DimNoPool "+ nopool.get(len)); + return true; + } + return false; + + } +} diff --git a/src/tconstruct/compat/mystcraft/MystImcHandler.java b/src/tconstruct/util/config/MystImcHandler.java similarity index 96% rename from src/tconstruct/compat/mystcraft/MystImcHandler.java rename to src/tconstruct/util/config/MystImcHandler.java index 452ce481..a1deb844 100644 --- a/src/tconstruct/compat/mystcraft/MystImcHandler.java +++ b/src/tconstruct/util/config/MystImcHandler.java @@ -1,4 +1,4 @@ -package tconstruct.compat.mystcraft; +package tconstruct.util.config; import net.minecraftforge.fluids.FluidStack; import cpw.mods.fml.common.event.FMLInterModComms; diff --git a/src/tconstruct/util/PHConstruct.java b/src/tconstruct/util/config/PHConstruct.java similarity index 99% rename from src/tconstruct/util/PHConstruct.java rename to src/tconstruct/util/config/PHConstruct.java index e508457c..47d94d59 100644 --- a/src/tconstruct/util/PHConstruct.java +++ b/src/tconstruct/util/config/PHConstruct.java @@ -1,4 +1,4 @@ -package tconstruct.util; +package tconstruct.util.config; import java.io.File; import java.io.IOException; diff --git a/src/tconstruct/util/config/TwilightForestConfig.java b/src/tconstruct/util/config/TwilightForestConfig.java new file mode 100644 index 00000000..96a34351 --- /dev/null +++ b/src/tconstruct/util/config/TwilightForestConfig.java @@ -0,0 +1,28 @@ +package tconstruct.util.config; + +import java.io.File; +import java.io.IOException; +import net.minecraftforge.common.Configuration; + +public class TwilightForestConfig +{ + public static void initProps (File location) + { + File newFile = new File(location + "/TwilightForest.cfg"); + if (newFile.exists()) + { + Configuration config = new Configuration(newFile); + + config.load(); + + twilightForestDimensionID = config.get("dimension", "dimensionID", -100).getInt(); + System.out.println("[TConstruct]TF Dim ID: " + twilightForestDimensionID); + } + else + { + twilightForestDimensionID = -100; + } + } + + public static int twilightForestDimensionID; +} diff --git a/src/tconstruct/util/player/TPlayerHandler.java b/src/tconstruct/util/player/TPlayerHandler.java index d872b258..d3f9f6ad 100644 --- a/src/tconstruct/util/player/TPlayerHandler.java +++ b/src/tconstruct/util/player/TPlayerHandler.java @@ -16,7 +16,7 @@ import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.event.entity.player.PlayerDropsEvent; import tconstruct.common.TContent; import tconstruct.library.tools.AbilityHelper; -import tconstruct.util.PHConstruct; +import tconstruct.util.config.PHConstruct; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.IPlayerTracker; import cpw.mods.fml.common.Loader; diff --git a/src/tconstruct/worldgen/OverworldProvider.java b/src/tconstruct/worldgen/OverworldProvider.java index ed03b3c0..b2524e5a 100644 --- a/src/tconstruct/worldgen/OverworldProvider.java +++ b/src/tconstruct/worldgen/OverworldProvider.java @@ -1,6 +1,6 @@ package tconstruct.worldgen; -import tconstruct.util.PHConstruct; +import tconstruct.util.config.PHConstruct; import net.minecraft.world.WorldProvider; public class OverworldProvider extends WorldProvider diff --git a/src/tconstruct/worldgen/SlimeIslandGen.java b/src/tconstruct/worldgen/SlimeIslandGen.java index 63dc1839..885b0900 100644 --- a/src/tconstruct/worldgen/SlimeIslandGen.java +++ b/src/tconstruct/worldgen/SlimeIslandGen.java @@ -10,8 +10,8 @@ import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenerator; import tconstruct.common.TContent; -import tconstruct.compat.dimensions.dimblacklist; -import tconstruct.util.PHConstruct; +import tconstruct.util.config.DimensionBlacklist; +import tconstruct.util.config.PHConstruct; import cpw.mods.fml.common.IWorldGenerator; public class SlimeIslandGen extends WorldGenerator implements IWorldGenerator @@ -33,7 +33,7 @@ public class SlimeIslandGen extends WorldGenerator implements IWorldGenerator @Override public void generate (Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) //IWorldGenerator version { - if (dimblacklist.isDimInBlacklist(world.provider.dimensionId)) + if (DimensionBlacklist.isDimInBlacklist(world.provider.dimensionId)) { if (random.nextInt(PHConstruct.islandRarity) == 0) generateIsland(world, random, chunkX * 16, chunkZ * 16); @@ -133,7 +133,7 @@ public class SlimeIslandGen extends WorldGenerator implements IWorldGenerator } //Decorate - if(!dimblacklist.isDimNoPool(world.provider.dimensionId)){ + if(!DimensionBlacklist.isDimNoPool(world.provider.dimensionId)){ generateSlimePool(world, rand, xChunk + xRange / 2, yCenter + initialHeight, zChunk + zRange / 2); } PlantGen tallGrass = new PlantGen(TContent.slimeTallGrass.blockID, 0, 128, xRange, 1, zRange, false); diff --git a/src/tconstruct/worldgen/SurfaceOreGen.java b/src/tconstruct/worldgen/SurfaceOreGen.java index e37da47f..de64e4ab 100644 --- a/src/tconstruct/worldgen/SurfaceOreGen.java +++ b/src/tconstruct/worldgen/SurfaceOreGen.java @@ -2,7 +2,7 @@ package tconstruct.worldgen; import java.util.Random; -import tconstruct.util.PHConstruct; +import tconstruct.util.config.PHConstruct; import net.minecraft.block.Block; import net.minecraft.util.MathHelper; diff --git a/src/tconstruct/worldgen/TBaseWorldGenerator.java b/src/tconstruct/worldgen/TBaseWorldGenerator.java index 15892b03..23a3aed3 100644 --- a/src/tconstruct/worldgen/TBaseWorldGenerator.java +++ b/src/tconstruct/worldgen/TBaseWorldGenerator.java @@ -9,7 +9,7 @@ import net.minecraft.world.WorldType; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenMinable; import tconstruct.common.TContent; -import tconstruct.util.PHConstruct; +import tconstruct.util.config.PHConstruct; import cpw.mods.fml.common.IWorldGenerator; public class TBaseWorldGenerator implements IWorldGenerator diff --git a/src/tconstruct/worldgen/TerrainGenEventHandler.java b/src/tconstruct/worldgen/TerrainGenEventHandler.java index 80bc9866..4ec1f400 100644 --- a/src/tconstruct/worldgen/TerrainGenEventHandler.java +++ b/src/tconstruct/worldgen/TerrainGenEventHandler.java @@ -7,7 +7,7 @@ import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.Ev import java.util.Random; import tconstruct.common.TContent; -import tconstruct.util.PHConstruct; +import tconstruct.util.config.PHConstruct; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase;