From 9986ffc458e6047f76c8aca6ba6b9cdd9504a1dc Mon Sep 17 00:00:00 2001 From: thatsIch Date: Sat, 3 Jan 2015 02:53:14 +0100 Subject: [PATCH] Fixes #675 No disabled feature should log spam or crash anymore. Deprecates the old usage of the AEItemDefinitions via the direct method access of * blocks() * parts() * items() * materials() and thus use the new re-direct via definitions(). All definitions are now initialized, no matter what. But SubItems, Items and Blocks are not registered, if by chance are disabled. --- src/api/java/appeng/api/AEApi.java | 31 +- src/api/java/appeng/api/IAppEngApi.java | 40 +- .../appeng/api/config/AccessRestriction.java | 41 +- .../java/appeng/api/config/ActionItems.java | 1 + .../java/appeng/api/config/Actionable.java | 1 + src/api/java/appeng/api/config/CopyMode.java | 1 + .../java/appeng/api/config/FullnessMode.java | 1 + src/api/java/appeng/api/config/FuzzyMode.java | 7 +- .../appeng/api/config/IncludeExclude.java | 1 + .../appeng/api/config/LevelEmitterMode.java | 1 + src/api/java/appeng/api/config/LevelType.java | 1 + .../java/appeng/api/config/ModSettings.java | 1 + .../appeng/api/config/NetworkEmitterMode.java | 1 + .../java/appeng/api/config/OperationMode.java | 1 + .../java/appeng/api/config/OutputMode.java | 1 + .../appeng/api/config/PowerMultiplier.java | 5 +- .../java/appeng/api/config/PowerUnits.java | 19 +- .../java/appeng/api/config/RedstoneMode.java | 1 + .../appeng/api/config/RelativeDirection.java | 1 + .../java/appeng/api/config/SearchBoxMode.java | 1 + .../api/config/SecurityPermissions.java | 1 + src/api/java/appeng/api/config/SortDir.java | 1 + src/api/java/appeng/api/config/SortOrder.java | 1 + .../java/appeng/api/config/StorageFilter.java | 1 + .../java/appeng/api/config/TerminalStyle.java | 1 + .../java/appeng/api/config/TunnelType.java | 2 +- src/api/java/appeng/api/config/Upgrades.java | 69 +- src/api/java/appeng/api/config/ViewItems.java | 1 + src/api/java/appeng/api/config/YesNo.java | 1 + .../java/appeng/api/definitions/Blocks.java | 67 +- .../api/definitions/IBlockDefinition.java | 21 + .../java/appeng/api/definitions/IBlocks.java | 164 ++++ .../definitions/IComparableDefinition.java | 32 + .../appeng/api/definitions/IDefinitions.java | 50 ++ .../api/definitions/IItemDefinition.java | 21 + .../java/appeng/api/definitions/IItems.java | 108 +++ .../appeng/api/definitions/IMaterials.java | 138 +++ .../java/appeng/api/definitions/IParts.java | 104 +++ .../api/definitions/ITileDefinition.java | 15 + .../java/appeng/api/definitions/Items.java | 37 +- .../appeng/api/definitions/Materials.java | 46 +- .../java/appeng/api/definitions/Parts.java | 34 +- .../api/events/LocatableEventAnnounce.java | 12 +- .../api/exceptions/AppEngException.java | 4 +- .../api/exceptions/CouldNotAccessCoreAPI.java | 10 + .../api/exceptions/FailedConnection.java | 4 +- .../api/exceptions/MissingDefinition.java | 10 + .../exceptions/MissingIngredientError.java | 8 +- .../api/exceptions/ModNotInstalled.java | 5 +- .../appeng/api/exceptions/RecipeError.java | 5 +- .../api/exceptions/RegistrationError.java | 5 +- .../appeng/api/features/IGrinderEntry.java | 2 + .../appeng/api/features/IGrinderRegistry.java | 17 +- .../appeng/api/features/IItemComparison.java | 3 +- .../api/features/IItemComparisonProvider.java | 7 +- .../java/appeng/api/features/ILocatable.java | 3 +- .../features/IMatterCannonAmmoRegistry.java | 10 +- .../api/features/INetworkEncodable.java | 13 +- .../api/features/IP2PTunnelRegistry.java | 7 +- .../appeng/api/features/IPlayerRegistry.java | 12 +- .../api/features/IRecipeHandlerRegistry.java | 21 +- .../api/features/IRegistryContainer.java | 2 + .../features/ISpecialComparisonRegistry.java | 7 +- .../api/features/IWirelessTermHandler.java | 17 +- .../api/features/IWirelessTermRegistry.java | 15 +- .../java/appeng/api/features/IWorldGen.java | 5 +- .../implementations/ICraftingPatternItem.java | 8 +- .../implementations/IPowerChannelState.java | 2 +- .../api/implementations/IUpgradeableHost.java | 8 +- .../api/implementations/TransitionResult.java | 4 +- .../implementations/guiobjects/IGuiItem.java | 5 +- .../guiobjects/IGuiItemObject.java | 2 + .../guiobjects/INetworkTool.java | 4 +- .../guiobjects/IPortableCell.java | 2 + .../items/IAEItemPowerStorage.java | 3 +- .../api/implementations/items/IAEWrench.java | 11 +- .../implementations/items/IBiometricCard.java | 35 +- .../items/IGrowableCrystal.java | 7 +- .../api/implementations/items/IItemGroup.java | 8 +- .../implementations/items/IMemoryCard.java | 21 +- .../items/ISpatialStorageCell.java | 27 +- .../implementations/items/IStorageCell.java | 29 +- .../items/IStorageComponent.java | 9 +- .../implementations/items/IUpgradeModule.java | 7 +- .../items/MemoryCardMessages.java | 1 + .../api/implementations/parts/IPartCable.java | 20 +- .../implementations/parts/IPartMonitor.java | 5 +- .../parts/IPartStorageMonitor.java | 7 +- .../implementations/tiles/IColorableTile.java | 6 +- .../tiles/ICraftingMachine.java | 2 + .../tiles/ICrystalGrowthAccelerator.java | 2 +- .../api/implementations/tiles/IMEChest.java | 2 + .../tiles/ISegmentedInventory.java | 6 +- .../tiles/ITileStorageMonitorable.java | 6 +- .../tiles/IViewCellStorage.java | 3 +- .../tiles/IWirelessAccessPoint.java | 3 +- .../java/appeng/api/movable/IMovableTile.java | 2 +- .../java/appeng/api/networking/GridFlags.java | 1 + .../api/networking/GridNotification.java | 1 + .../api/networking/IGridCacheRegistry.java | 7 +- .../api/networking/IGridMultiblock.java | 3 +- .../java/appeng/api/networking/IGridNode.java | 8 +- .../appeng/api/networking/IGridStorage.java | 3 +- .../appeng/api/networking/IMachineSet.java | 3 +- .../networking/crafting/CraftingItemList.java | 1 + .../api/networking/crafting/ICraftingCPU.java | 3 +- .../networking/crafting/ICraftingGrid.java | 13 +- .../api/networking/crafting/ICraftingJob.java | 7 +- .../networking/crafting/ICraftingLink.java | 5 +- .../networking/crafting/ICraftingMedium.java | 8 +- .../crafting/ICraftingPatternDetails.java | 2 + .../crafting/ICraftingProvider.java | 5 +- .../crafting/ICraftingProviderHelper.java | 7 +- .../crafting/ICraftingRequester.java | 5 +- .../networking/crafting/ICraftingWatcher.java | 2 + .../crafting/ICraftingWatcherHost.java | 9 +- .../energy/IEnergyGridProvider.java | 4 +- .../api/networking/energy/IEnergyWatcher.java | 2 + .../networking/energy/IEnergyWatcherHost.java | 6 +- .../events/MENetworkChannelChanged.java | 6 +- .../events/MENetworkControllerChange.java | 1 + .../events/MENetworkCraftingCpuChange.java | 6 +- .../MENetworkCraftingPatternChange.java | 6 +- .../events/MENetworkEventSubscribe.java | 7 +- .../MENetworkPostCacheConstruction.java | 1 + .../events/MENetworkSecurityChange.java | 1 + .../events/MENetworkSpatialEvent.java | 5 +- .../networking/pathing/ControllerState.java | 1 + .../api/networking/pathing/IPathingGrid.java | 5 +- .../networking/security/BaseActionSource.java | 2 +- .../api/networking/security/IActionHost.java | 5 +- .../networking/security/ISecurityGrid.java | 2 + .../security/ISecurityProvider.java | 7 +- .../security/ISecurityRegistry.java | 3 +- .../networking/security/MachineSource.java | 5 +- .../api/networking/security/PlayerSource.java | 6 +- .../api/networking/spatial/ISpatialCache.java | 3 +- .../api/networking/storage/IBaseMonitor.java | 7 +- .../api/networking/storage/IStackWatcher.java | 2 + .../ticking/TickRateModulation.java | 1 + src/api/java/appeng/api/package-info.java | 4 +- src/api/java/appeng/api/parts/BusSupport.java | 1 + .../appeng/api/parts/CableRenderMode.java | 9 +- .../java/appeng/api/parts/IAlphaPassItem.java | 6 +- .../java/appeng/api/parts/IBoxProvider.java | 4 +- .../appeng/api/parts/IFacadeContainer.java | 8 +- .../java/appeng/api/parts/IFacadePart.java | 2 + src/api/java/appeng/api/parts/IPart.java | 94 +- src/api/java/appeng/api/parts/IPartHost.java | 8 +- src/api/java/appeng/api/parts/IPartItem.java | 6 +- .../appeng/api/parts/IPartRenderHelper.java | 8 +- src/api/java/appeng/api/parts/LayerBase.java | 5 +- src/api/java/appeng/api/parts/LayerFlags.java | 1 + .../java/appeng/api/parts/PartItemStack.java | 1 + .../java/appeng/api/parts/SelectedPart.java | 12 +- .../appeng/api/recipes/IRecipeHandler.java | 6 +- .../appeng/api/recipes/IRecipeLoader.java | 5 +- .../appeng/api/recipes/ISubItemResolver.java | 6 +- .../appeng/api/recipes/ResolverResult.java | 9 +- .../appeng/api/recipes/ResolverResultSet.java | 6 +- .../appeng/api/storage/ICellContainer.java | 5 +- .../java/appeng/api/storage/ICellHandler.java | 5 +- .../appeng/api/storage/ICellInventory.java | 4 +- .../api/storage/ICellInventoryHandler.java | 3 +- .../appeng/api/storage/ICellRegistry.java | 2 + .../api/storage/ICellWorkbenchItem.java | 2 + .../api/storage/IExternalStorageHandler.java | 2 + .../api/storage/IExternalStorageRegistry.java | 2 + .../java/appeng/api/storage/IMEMonitor.java | 3 +- .../storage/IMEMonitorHandlerReceiver.java | 8 +- .../appeng/api/storage/ISaveProvider.java | 3 +- .../appeng/api/storage/IStorageHelper.java | 15 +- .../appeng/api/storage/ITerminalHost.java | 2 + .../appeng/api/storage/MEMonitorHandler.java | 12 +- .../appeng/api/storage/StorageChannel.java | 8 +- .../appeng/api/storage/data/IAEStack.java | 11 +- src/api/java/appeng/api/util/AECableType.java | 1 + src/api/java/appeng/api/util/AEColor.java | 7 + .../api/util/AEColoredItemDefinition.java | 24 +- .../appeng/api/util/AEItemDefinition.java | 48 +- .../appeng/api/util/DimensionalCoord.java | 19 +- src/api/java/appeng/api/util/ICommonTile.java | 13 +- .../java/appeng/api/util/IConfigManager.java | 12 +- .../appeng/api/util/IConfigurableObject.java | 2 +- .../appeng/api/util/INetworkToolAgent.java | 5 +- .../appeng/api/util/IOrientableBlock.java | 12 +- .../appeng/api/util/IReadOnlyCollection.java | 4 +- src/api/java/appeng/api/util/WorldCoord.java | 30 +- .../block/AEBaseItemBlockChargeable.java | 23 +- .../block/crafting/BlockCraftingMonitor.java | 47 +- .../block/crafting/ItemCraftingStorage.java | 8 +- .../java/appeng/block/misc/BlockCharger.java | 5 +- .../block/networking/BlockCableBus.java | 4 +- .../java/appeng/block/solids/OreQuartz.java | 50 +- .../appeng/block/solids/OreQuartzCharged.java | 18 +- .../block/stair/ChiseledQuartzStairBlock.java | 7 +- .../appeng/block/stair/FluixStairBlock.java | 2 +- .../block/stair/QuartzPillarStairBlock.java | 7 +- .../appeng/block/stair/QuartzStairBlock.java | 7 +- .../block/stair/SkyStoneBlockStairBlock.java | 2 +- .../block/stair/SkyStoneBrickStairBlock.java | 2 +- .../stair/SkyStoneSmallBrickStairBlock.java | 2 +- .../block/stair/SkyStoneStairBlock.java | 2 +- .../appeng/block/storage/BlockSkyChest.java | 11 +- src/main/java/appeng/client/ClientHelper.java | 8 +- .../gui/implementations/GuiCraftAmount.java | 112 ++- .../gui/implementations/GuiCraftConfirm.java | 2 +- .../implementations/GuiCraftingStatus.java | 57 +- .../client/gui/implementations/GuiIOPort.java | 16 +- .../gui/implementations/GuiPriority.java | 85 +- .../client/gui/widgets/GuiImgButton.java | 7 +- .../appeng/client/render/BaseBlockRender.java | 536 +++++------ .../appeng/client/render/BusRenderHelper.java | 465 ++++++---- .../render/blocks/RenderBlockCraftingCPU.java | 8 +- .../client/render/blocks/RenderQNB.java | 165 ++-- .../render/blocks/RenderQuartzGlass.java | 13 +- .../client/render/blocks/RenderQuartzOre.java | 4 +- .../implementations/ContainerInscriber.java | 8 +- .../ContainerMEMonitorable.java | 6 +- .../implementations/ContainerPatternTerm.java | 14 +- .../implementations/ContainerQuartzKnife.java | 11 +- .../container/slot/SlotRestrictedInput.java | 165 ++-- src/main/java/appeng/core/AEConfig.java | 6 +- src/main/java/appeng/core/AELog.java | 2 +- src/main/java/appeng/core/Api.java | 64 +- src/main/java/appeng/core/ApiDefinitions.java | 89 ++ src/main/java/appeng/core/AppEng.java | 2 +- src/main/java/appeng/core/CreativeTab.java | 32 +- .../java/appeng/core/CreativeTabFacade.java | 11 +- .../appeng/core/FeatureHandlerRegistry.java | 41 + .../java/appeng/core/FeatureRegistry.java | 41 + src/main/java/appeng/core/Registration.java | 810 ++++++++--------- src/main/java/appeng/core/WorldSettings.java | 2 +- .../core/api/definitions/ApiBlocks.java | 599 +++++++++++++ .../appeng/core/api/definitions/ApiItems.java | 418 +++++++++ .../core/api/definitions/ApiMaterials.java | 507 +++++++++++ .../appeng/core/api/definitions/ApiParts.java | 328 +++++++ .../definitions/DefinitionConstructor.java | 105 +++ .../core/features/AEBlockFeatureHandler.java | 26 +- .../core/features/AEFeatureHandler.java | 266 ------ .../appeng/core/features/ActivityState.java | 7 + .../appeng/core/features/BlockDefinition.java | 53 +- .../core/features/ColoredItemDefinition.java | 2 +- .../core/features/DamagedItemDefinition.java | 51 +- .../core/features/DefinitionConverter.java | 160 ++++ .../core/features/FeaturedActiveChecker.java | 12 +- .../appeng/core/features/IFeatureHandler.java | 8 +- .../appeng/core/features/ItemDefinition.java | 40 +- .../core/features/ItemFeatureHandler.java | 67 +- .../core/features/MaterialStackSrc.java | 12 +- .../appeng/core/features/NameResolver.java | 75 ++ .../core/features/NullItemDefinition.java | 68 -- .../features/StairBlockFeatureHandler.java | 39 +- ...ockDefinition.java => TileDefinition.java} | 15 +- .../features/WrappedDamageItemDefinition.java | 77 +- .../registries/P2PTunnelRegistry.java | 37 +- .../java/appeng/core/stats/Achievements.java | 59 +- src/main/java/appeng/core/sync/GuiBridge.java | 34 +- .../appeng/core/sync/packets/PacketClick.java | 39 +- .../core/sync/packets/PacketValueConfig.java | 9 +- src/main/java/appeng/debug/ToolDebugCard.java | 53 +- src/main/java/appeng/debug/ToolEraser.java | 44 +- .../appeng/debug/ToolMeteoritePlacer.java | 27 +- .../java/appeng/debug/ToolReplicatorCard.java | 20 +- .../appeng/entity/EntityChargedQuartz.java | 16 +- .../java/appeng/entity/EntitySingularity.java | 23 +- .../appeng/entity/EntityTinyTNTPrimed.java | 27 +- .../java/appeng/facade/FacadeContainer.java | 13 +- src/main/java/appeng/fmp/PartRegistry.java | 2 +- src/main/java/appeng/fmp/QuartzTorchPart.java | 9 +- .../java/appeng/helpers/DualityInterface.java | 8 +- .../java/appeng/helpers/MeteoritePlacer.java | 846 ------------------ src/main/java/appeng/helpers/Reflected.java | 18 + src/main/java/appeng/hooks/AETrading.java | 92 +- .../java/appeng/integration/modules/BC.java | 259 +++--- .../java/appeng/integration/modules/FMP.java | 45 +- .../modules/ImmibisMicroblocks.java | 36 +- .../NEIHelpers/NEIFacadeRecipeHandler.java | 142 +-- .../NEIHelpers/NEIWorldCraftingHandler.java | 60 +- .../integration/modules/helpers/BSCrate.java | 39 +- src/main/java/appeng/items/AEBaseItem.java | 16 +- .../appeng/items/contents/CellUpgrades.java | 13 +- .../items/materials/ItemMultiMaterial.java | 348 +++---- .../appeng/items/misc/ItemCrystalSeed.java | 169 ++-- .../appeng/items/misc/ItemEncodedPattern.java | 87 +- .../java/appeng/items/misc/ItemPaintBall.java | 35 +- .../java/appeng/items/parts/ItemFacade.java | 192 ++-- .../appeng/items/parts/ItemMultiPart.java | 73 +- .../java/appeng/items/parts/PartType.java | 111 ++- .../items/storage/ItemBasicStorageCell.java | 27 +- .../storage/ItemCreativeStorageCell.java | 16 +- .../items/storage/ItemSpatialStorageCell.java | 14 +- .../appeng/items/storage/ItemViewCell.java | 116 ++- .../appeng/items/tools/ToolBiometricCard.java | 121 +-- .../appeng/items/tools/ToolMemoryCard.java | 108 +-- .../appeng/items/tools/ToolNetworkTool.java | 5 +- .../items/tools/powered/ToolChargedStaff.java | 7 +- .../tools/powered/ToolColorApplicator.java | 7 +- .../tools/powered/ToolEntropyManipulator.java | 4 +- .../items/tools/powered/ToolMassCannon.java | 12 +- .../items/tools/powered/ToolPortableCell.java | 7 +- .../tools/powered/ToolWirelessTerminal.java | 9 +- .../powered/powersink/AEBasePoweredItem.java | 7 +- .../powered/powersink/AERootPoweredItem.java | 29 +- .../items/tools/powered/powersink/IC2.java | 10 +- .../tools/powered/powersink/RedstoneFlux.java | 17 +- .../tools/quartz/ToolQuartzCuttingKnife.java | 14 +- .../items/tools/quartz/ToolQuartzWrench.java | 5 +- .../implementations/QuantumCalculator.java | 26 +- .../appeng/me/storage/SecurityInventory.java | 17 +- src/main/java/appeng/parts/AEBasePart.java | 15 +- .../java/appeng/parts/PartBasicState.java | 65 +- src/main/java/appeng/parts/PartPlacement.java | 189 ++-- .../automation/BlockUpgradeInventory.java | 41 + .../DefinitionUpgradeInventory.java | 38 + .../automation/PartAnnihilationPlane.java | 296 +++--- .../parts/automation/PartExportBus.java | 352 ++++---- .../parts/automation/PartFormationPlane.java | 301 ++++--- .../parts/automation/PartImportBus.java | 237 +++-- .../parts/automation/PartLevelEmitter.java | 472 +++++----- .../parts/automation/PartSharedItemBus.java | 100 +-- .../parts/automation/PartUpgradeable.java | 119 +-- .../automation/StackUpgradeInventory.java | 37 + .../parts/automation/UpgradeInventory.java | 206 ++--- .../java/appeng/parts/misc/PartInterface.java | 221 +++-- .../parts/misc/PartInvertedToggleBus.java | 12 +- .../appeng/parts/misc/PartStorageBus.java | 378 ++++---- .../java/appeng/parts/misc/PartToggleBus.java | 281 +++--- .../appeng/parts/networking/PartCable.java | 37 +- .../parts/networking/PartCableCovered.java | 169 ++-- .../parts/networking/PartCableGlass.java | 16 +- .../parts/networking/PartCableSmart.java | 260 +++--- .../parts/networking/PartDenseCable.java | 644 ++++++------- .../parts/networking/PartQuartzFiber.java | 2 +- .../appeng/parts/p2p/PartP2PIC2Power.java | 12 - .../java/appeng/parts/p2p/PartP2PItems.java | 7 - .../java/appeng/parts/p2p/PartP2PLight.java | 7 - .../java/appeng/parts/p2p/PartP2PLiquids.java | 7 - .../java/appeng/parts/p2p/PartP2PRFPower.java | 14 - .../appeng/parts/p2p/PartP2PRedstone.java | 7 - .../java/appeng/parts/p2p/PartP2PTunnel.java | 388 ++++---- .../appeng/parts/p2p/PartP2PTunnelME.java | 7 - .../reporting/PartConversionMonitor.java | 21 +- .../parts/reporting/PartCraftingTerminal.java | 54 +- .../parts/reporting/PartDarkMonitor.java | 23 +- .../reporting/PartInterfaceTerminal.java | 9 +- .../appeng/parts/reporting/PartMonitor.java | 8 +- .../parts/reporting/PartPatternTerminal.java | 109 +-- .../parts/reporting/PartSemiDarkMonitor.java | 28 +- .../parts/reporting/PartStorageMonitor.java | 202 ++--- .../appeng/parts/reporting/PartTerminal.java | 102 +-- .../java/appeng/recipes/AEItemResolver.java | 48 +- .../java/appeng/recipes/RecipeHandler.java | 25 +- .../recipes/game/DisassembleRecipe.java | 109 ++- .../appeng/recipes/game/FacadeRecipe.java | 40 +- src/main/java/appeng/server/AECommand.java | 12 +- .../java/appeng/services/CompassService.java | 290 +++--- src/main/java/appeng/spatial/CachedPlane.java | 231 +++-- .../appeng/spatial/StorageChunkProvider.java | 55 +- .../java/appeng/spatial/StorageHelper.java | 8 +- .../crafting/TileCraftingStorageTile.java | 37 +- .../tile/crafting/TileCraftingTile.java | 199 ++-- .../tile/crafting/TileMolecularAssembler.java | 422 ++++----- .../inventory/AppEngInternalInventory.java | 246 ++--- .../java/appeng/tile/misc/TileCharger.java | 36 +- .../java/appeng/tile/misc/TileCondenser.java | 24 +- .../java/appeng/tile/misc/TileInscriber.java | 254 +++--- .../appeng/tile/networking/TileWireless.java | 2 +- .../appeng/tile/qnb/TileQuantumBridge.java | 178 ++-- .../java/appeng/tile/storage/TileIOPort.java | 121 +-- .../transformer/annotations/Integration.java | 4 +- src/main/java/appeng/util/ConfigManager.java | 141 +-- src/main/java/appeng/util/Platform.java | 48 +- .../java/appeng/util/item/AEItemStack.java | 14 +- .../java/appeng/worldgen/MeteoritePlacer.java | 513 +++++++++++ .../MeteoriteWorldGen.java | 30 +- .../{hooks => worldgen}/QuartzWorldGen.java | 38 +- .../appeng/worldgen/meteorite/ChunkOnly.java | 98 ++ .../appeng/worldgen/meteorite/Fallout.java | 61 ++ .../worldgen/meteorite/FalloutCopy.java | 64 ++ .../worldgen/meteorite/FalloutSand.java | 32 + .../worldgen/meteorite/FalloutSnow.java | 39 + .../worldgen/meteorite/IMeteoriteWorld.java | 36 + .../meteorite/MeteoriteBlockPutter.java | 30 + .../worldgen/meteorite/StandardWorld.java | 113 +++ 385 files changed, 12477 insertions(+), 8292 deletions(-) create mode 100644 src/api/java/appeng/api/definitions/IBlockDefinition.java create mode 100644 src/api/java/appeng/api/definitions/IBlocks.java create mode 100644 src/api/java/appeng/api/definitions/IComparableDefinition.java create mode 100644 src/api/java/appeng/api/definitions/IDefinitions.java create mode 100644 src/api/java/appeng/api/definitions/IItemDefinition.java create mode 100644 src/api/java/appeng/api/definitions/IItems.java create mode 100644 src/api/java/appeng/api/definitions/IMaterials.java create mode 100644 src/api/java/appeng/api/definitions/IParts.java create mode 100644 src/api/java/appeng/api/definitions/ITileDefinition.java create mode 100644 src/api/java/appeng/api/exceptions/CouldNotAccessCoreAPI.java create mode 100644 src/api/java/appeng/api/exceptions/MissingDefinition.java create mode 100644 src/main/java/appeng/core/ApiDefinitions.java create mode 100644 src/main/java/appeng/core/FeatureHandlerRegistry.java create mode 100644 src/main/java/appeng/core/FeatureRegistry.java create mode 100644 src/main/java/appeng/core/api/definitions/ApiBlocks.java create mode 100644 src/main/java/appeng/core/api/definitions/ApiItems.java create mode 100644 src/main/java/appeng/core/api/definitions/ApiMaterials.java create mode 100644 src/main/java/appeng/core/api/definitions/ApiParts.java create mode 100644 src/main/java/appeng/core/api/definitions/DefinitionConstructor.java delete mode 100644 src/main/java/appeng/core/features/AEFeatureHandler.java create mode 100644 src/main/java/appeng/core/features/ActivityState.java create mode 100644 src/main/java/appeng/core/features/DefinitionConverter.java create mode 100644 src/main/java/appeng/core/features/NameResolver.java delete mode 100644 src/main/java/appeng/core/features/NullItemDefinition.java rename src/main/java/appeng/core/features/{AEBlockDefinition.java => TileDefinition.java} (69%) delete mode 100644 src/main/java/appeng/helpers/MeteoritePlacer.java create mode 100644 src/main/java/appeng/helpers/Reflected.java create mode 100644 src/main/java/appeng/parts/automation/BlockUpgradeInventory.java create mode 100644 src/main/java/appeng/parts/automation/DefinitionUpgradeInventory.java create mode 100644 src/main/java/appeng/parts/automation/StackUpgradeInventory.java create mode 100644 src/main/java/appeng/worldgen/MeteoritePlacer.java rename src/main/java/appeng/{hooks => worldgen}/MeteoriteWorldGen.java (85%) rename src/main/java/appeng/{hooks => worldgen}/QuartzWorldGen.java (69%) create mode 100644 src/main/java/appeng/worldgen/meteorite/ChunkOnly.java create mode 100644 src/main/java/appeng/worldgen/meteorite/Fallout.java create mode 100644 src/main/java/appeng/worldgen/meteorite/FalloutCopy.java create mode 100644 src/main/java/appeng/worldgen/meteorite/FalloutSand.java create mode 100644 src/main/java/appeng/worldgen/meteorite/FalloutSnow.java create mode 100644 src/main/java/appeng/worldgen/meteorite/IMeteoriteWorld.java create mode 100644 src/main/java/appeng/worldgen/meteorite/MeteoriteBlockPutter.java create mode 100644 src/main/java/appeng/worldgen/meteorite/StandardWorld.java diff --git a/src/api/java/appeng/api/AEApi.java b/src/api/java/appeng/api/AEApi.java index f6e7e665f..d211054cd 100644 --- a/src/api/java/appeng/api/AEApi.java +++ b/src/api/java/appeng/api/AEApi.java @@ -23,39 +23,46 @@ package appeng.api; + +import appeng.api.exceptions.CouldNotAccessCoreAPI; + + /** - * * Entry point for api. * * Available IMCs: - * */ -public class AEApi +public enum AEApi { + ; + private static final String CORE_API_PATH = "appeng.core.Api"; + private static final String API_INSTANCE_NAME = "INSTANCE"; - static private IAppEngApi api = null; + private static IAppEngApi instance = null; /** * API Entry Point. * - * @return the {@link IAppEngApi} or null if the INSTANCE could not be retrieved + * @return the {@link IAppEngApi} + * + * @throws CouldNotAccessCoreAPI if the INSTANCE could not be retrieved */ public static IAppEngApi instance() + { - if ( api == null ) + if ( instance == null ) { try { - Class c = Class.forName( "appeng.core.Api" ); - api = (IAppEngApi) c.getField( "INSTANCE" ).get( c ); + Class c = Class.forName( CORE_API_PATH ); + instance = (IAppEngApi) c.getField( API_INSTANCE_NAME ).get( c ); } - catch (Throwable e) + catch ( Throwable e ) { - return null; + throw new CouldNotAccessCoreAPI( "Either core API was not in " + CORE_API_PATH + " or " + API_INSTANCE_NAME + " was not accessible" ); } } - return api; + return instance; } - } diff --git a/src/api/java/appeng/api/IAppEngApi.java b/src/api/java/appeng/api/IAppEngApi.java index cb4910a2a..8c3f127e2 100644 --- a/src/api/java/appeng/api/IAppEngApi.java +++ b/src/api/java/appeng/api/IAppEngApi.java @@ -23,7 +23,9 @@ package appeng.api; + import appeng.api.definitions.Blocks; +import appeng.api.definitions.IDefinitions; import appeng.api.definitions.Items; import appeng.api.definitions.Materials; import appeng.api.definitions.Parts; @@ -31,11 +33,11 @@ import appeng.api.exceptions.FailedConnection; import appeng.api.features.IRegistryContainer; import appeng.api.networking.IGridBlock; import appeng.api.networking.IGridConnection; -import appeng.api.networking.IGridHost; import appeng.api.networking.IGridNode; import appeng.api.parts.IPartHelper; import appeng.api.storage.IStorageHelper; + public interface IAppEngApi { @@ -56,39 +58,57 @@ public interface IAppEngApi /** * @return an accessible list of all of AE's Items + * + * @deprecated use {@link appeng.api.definitions.IDefinitions#items()} */ + @Deprecated Items items(); /** * @return an accessible list of all of AE's materials; materials are items + * + * @deprecated use {@link appeng.api.definitions.IDefinitions#materials()} */ + @Deprecated Materials materials(); /** * @return an accessible list of all of AE's blocks + * + * @deprecated use {@link appeng.api.definitions.IDefinitions#blocks()} */ + @Deprecated Blocks blocks(); /** * @return an accessible list of all of AE's parts, parts are items + * + * @deprecated use {@link appeng.api.definitions.IDefinitions#parts()} */ + @Deprecated Parts parts(); /** - * create a grid node for your {@link IGridHost} - * - * @param block grid block - * @return grid node of block + * @return an accessible list of all AE definitions */ - IGridNode createGridNode(IGridBlock block); + IDefinitions definitions(); /** - * create a connection between two {@link IGridNode} + * create a grid node for your {@link appeng.api.networking.IGridHost} + * + * @param block grid block + * + * @return grid node of block + */ + IGridNode createGridNode( IGridBlock block ); + + /** + * create a connection between two {@link appeng.api.networking.IGridNode} * * @param a to be connected gridnode * @param b to be connected gridnode - * @throws FailedConnection + * + * @throws appeng.api.exceptions.FailedConnection */ - IGridConnection createGridConnection(IGridNode a, IGridNode b) throws FailedConnection; - + IGridConnection createGridConnection( IGridNode a, IGridNode b ) throws FailedConnection; } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/AccessRestriction.java b/src/api/java/appeng/api/config/AccessRestriction.java index b15b3e1d4..cd1ae993c 100644 --- a/src/api/java/appeng/api/config/AccessRestriction.java +++ b/src/api/java/appeng/api/config/AccessRestriction.java @@ -23,9 +23,10 @@ package appeng.api.config; + public enum AccessRestriction { - NO_ACCESS(0), READ(1), WRITE(2), READ_WRITE(3); + NO_ACCESS( 0 ), READ( 1 ), WRITE( 2 ), READ_WRITE( 3 ); private final int permissionBit; @@ -33,39 +34,39 @@ public enum AccessRestriction this.permissionBit = v; } - public boolean hasPermission(AccessRestriction ar) + public boolean hasPermission( AccessRestriction ar ) { - return ( this.permissionBit & ar.permissionBit) == ar.permissionBit; + return ( this.permissionBit & ar.permissionBit ) == ar.permissionBit; } - public AccessRestriction restrictPermissions(AccessRestriction ar) + public AccessRestriction restrictPermissions( AccessRestriction ar ) { - return this.getPermByBit( this.permissionBit & ar.permissionBit); + return this.getPermByBit( this.permissionBit & ar.permissionBit ); } - public AccessRestriction addPermissions(AccessRestriction ar) + public AccessRestriction addPermissions( AccessRestriction ar ) { - return this.getPermByBit( this.permissionBit | ar.permissionBit); + return this.getPermByBit( this.permissionBit | ar.permissionBit ); } - public AccessRestriction removePermissions(AccessRestriction ar) + public AccessRestriction removePermissions( AccessRestriction ar ) { - return this.getPermByBit( this.permissionBit & (~ar.permissionBit) ); + return this.getPermByBit( this.permissionBit & ( ~ar.permissionBit ) ); } - private AccessRestriction getPermByBit(int bit) + private AccessRestriction getPermByBit( int bit ) { - switch (bit) + switch ( bit ) { - default: - case 0: - return NO_ACCESS; - case 1: - return READ; - case 2: - return WRITE; - case 3: - return READ_WRITE; + default: + case 0: + return NO_ACCESS; + case 1: + return READ; + case 2: + return WRITE; + case 3: + return READ_WRITE; } } } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/ActionItems.java b/src/api/java/appeng/api/config/ActionItems.java index 357d69364..9cb6fbf28 100644 --- a/src/api/java/appeng/api/config/ActionItems.java +++ b/src/api/java/appeng/api/config/ActionItems.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum ActionItems { WRENCH, CLOSE, STASH, ENCODE, SUBSTITUTION diff --git a/src/api/java/appeng/api/config/Actionable.java b/src/api/java/appeng/api/config/Actionable.java index dc5665d01..8e5f1f542 100644 --- a/src/api/java/appeng/api/config/Actionable.java +++ b/src/api/java/appeng/api/config/Actionable.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum Actionable { /** diff --git a/src/api/java/appeng/api/config/CopyMode.java b/src/api/java/appeng/api/config/CopyMode.java index 999e80c22..7f2f39969 100644 --- a/src/api/java/appeng/api/config/CopyMode.java +++ b/src/api/java/appeng/api/config/CopyMode.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum CopyMode { CLEAR_ON_REMOVE, KEEP_ON_REMOVE diff --git a/src/api/java/appeng/api/config/FullnessMode.java b/src/api/java/appeng/api/config/FullnessMode.java index 5f186e202..c52d4228f 100644 --- a/src/api/java/appeng/api/config/FullnessMode.java +++ b/src/api/java/appeng/api/config/FullnessMode.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum FullnessMode { EMPTY, HALF, FULL diff --git a/src/api/java/appeng/api/config/FuzzyMode.java b/src/api/java/appeng/api/config/FuzzyMode.java index f7e276d4b..460f56676 100644 --- a/src/api/java/appeng/api/config/FuzzyMode.java +++ b/src/api/java/appeng/api/config/FuzzyMode.java @@ -23,10 +23,11 @@ package appeng.api.config; + public enum FuzzyMode { // Note that percentage damaged, is the inverse of percentage durability. - IGNORE_ALL(-1), PERCENT_99(0), PERCENT_75(25), PERCENT_50(50), PERCENT_25(75); + IGNORE_ALL( -1 ), PERCENT_99( 0 ), PERCENT_75( 25 ), PERCENT_50( 50 ), PERCENT_25( 75 ); final public float breakPoint; final public float percentage; @@ -36,9 +37,9 @@ public enum FuzzyMode this.breakPoint = p / 100.0f; } - public int calculateBreakPoint(int maxDamage) + public int calculateBreakPoint( int maxDamage ) { - return (int) (( this.percentage * maxDamage) / 100.0f); + return (int) ( ( this.percentage * maxDamage ) / 100.0f ); } } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/IncludeExclude.java b/src/api/java/appeng/api/config/IncludeExclude.java index 379e1463a..53f0bbeb7 100644 --- a/src/api/java/appeng/api/config/IncludeExclude.java +++ b/src/api/java/appeng/api/config/IncludeExclude.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum IncludeExclude { WHITELIST, BLACKLIST diff --git a/src/api/java/appeng/api/config/LevelEmitterMode.java b/src/api/java/appeng/api/config/LevelEmitterMode.java index 33ea5fddd..dcdd0ef88 100644 --- a/src/api/java/appeng/api/config/LevelEmitterMode.java +++ b/src/api/java/appeng/api/config/LevelEmitterMode.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum LevelEmitterMode { diff --git a/src/api/java/appeng/api/config/LevelType.java b/src/api/java/appeng/api/config/LevelType.java index 58910886f..0787abb75 100644 --- a/src/api/java/appeng/api/config/LevelType.java +++ b/src/api/java/appeng/api/config/LevelType.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum LevelType { diff --git a/src/api/java/appeng/api/config/ModSettings.java b/src/api/java/appeng/api/config/ModSettings.java index 0678f3449..b12258446 100644 --- a/src/api/java/appeng/api/config/ModSettings.java +++ b/src/api/java/appeng/api/config/ModSettings.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum ModSettings { diff --git a/src/api/java/appeng/api/config/NetworkEmitterMode.java b/src/api/java/appeng/api/config/NetworkEmitterMode.java index 5ddd09320..03efd7c98 100644 --- a/src/api/java/appeng/api/config/NetworkEmitterMode.java +++ b/src/api/java/appeng/api/config/NetworkEmitterMode.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum NetworkEmitterMode { diff --git a/src/api/java/appeng/api/config/OperationMode.java b/src/api/java/appeng/api/config/OperationMode.java index e470faed5..f2c8ff30e 100644 --- a/src/api/java/appeng/api/config/OperationMode.java +++ b/src/api/java/appeng/api/config/OperationMode.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum OperationMode { FILL, EMPTY diff --git a/src/api/java/appeng/api/config/OutputMode.java b/src/api/java/appeng/api/config/OutputMode.java index 3d03335d6..f9bcffa57 100644 --- a/src/api/java/appeng/api/config/OutputMode.java +++ b/src/api/java/appeng/api/config/OutputMode.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum OutputMode { EXPORT_ONLY, EXPORT_OR_CRAFT, CRAFT_ONLY diff --git a/src/api/java/appeng/api/config/PowerMultiplier.java b/src/api/java/appeng/api/config/PowerMultiplier.java index 4487b32ec..a2029f8ce 100644 --- a/src/api/java/appeng/api/config/PowerMultiplier.java +++ b/src/api/java/appeng/api/config/PowerMultiplier.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum PowerMultiplier { ONE, CONFIG; @@ -32,12 +33,12 @@ public enum PowerMultiplier */ public double multiplier = 1.0; - public double multiply(double in) + public double multiply( double in ) { return in * this.multiplier; } - public double divide(double in) + public double divide( double in ) { return in / this.multiplier; } diff --git a/src/api/java/appeng/api/config/PowerUnits.java b/src/api/java/appeng/api/config/PowerUnits.java index 237a17c2c..88ecd318e 100644 --- a/src/api/java/appeng/api/config/PowerUnits.java +++ b/src/api/java/appeng/api/config/PowerUnits.java @@ -23,14 +23,14 @@ package appeng.api.config; + public enum PowerUnits { - AE("gui.appliedenergistics2.units.appliedenergstics"), // Native Units - AE Energy - MJ("gui.appliedenergistics2.units.buildcraft"), // BuildCraft - Minecraft Joules - EU("gui.appliedenergistics2.units.ic2"), // IndustrialCraft 2 - Energy Units - WA("gui.appliedenergistics2.units.rotarycraft"), // RotaryCraft - Watts - RF("gui.appliedenergistics2.units.thermalexpansion"), // ThermalExpansion - Redstone Flux - MK("gui.appliedenergistics2.units.mekanism"); // Mekanism - Joules + AE( "gui.appliedenergistics2.units.appliedenergstics" ), // Native Units - AE Energy + EU( "gui.appliedenergistics2.units.ic2" ), // IndustrialCraft 2 - Energy Units + WA( "gui.appliedenergistics2.units.rotarycraft" ), // RotaryCraft - Watts + RF( "gui.appliedenergistics2.units.thermalexpansion" ), // ThermalExpansion - Redstone Flux + MK( "gui.appliedenergistics2.units.mekanism" ); // Mekanism - Joules PowerUnits( String un ) { this.unlocalizedName = un; @@ -54,12 +54,13 @@ public enum PowerUnits * will normally returns 64, as it will convert the EU, to AE with AE's power settings. * * @param target target power unit - * @param value value + * @param value value + * * @return value converted to target units, from this units. */ - public double convertTo(PowerUnits target, double value) + public double convertTo( PowerUnits target, double value ) { - return (value * this.conversionRatio ) / target.conversionRatio; + return ( value * this.conversionRatio ) / target.conversionRatio; } } \ No newline at end of file diff --git a/src/api/java/appeng/api/config/RedstoneMode.java b/src/api/java/appeng/api/config/RedstoneMode.java index 636dfbe09..0bb5a54da 100644 --- a/src/api/java/appeng/api/config/RedstoneMode.java +++ b/src/api/java/appeng/api/config/RedstoneMode.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum RedstoneMode { IGNORE, LOW_SIGNAL, HIGH_SIGNAL, SIGNAL_PULSE diff --git a/src/api/java/appeng/api/config/RelativeDirection.java b/src/api/java/appeng/api/config/RelativeDirection.java index 843e96995..a81d20473 100644 --- a/src/api/java/appeng/api/config/RelativeDirection.java +++ b/src/api/java/appeng/api/config/RelativeDirection.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum RelativeDirection { LEFT, RIGHT, UP, DOW diff --git a/src/api/java/appeng/api/config/SearchBoxMode.java b/src/api/java/appeng/api/config/SearchBoxMode.java index 2f2af1fd3..f2f2408e2 100644 --- a/src/api/java/appeng/api/config/SearchBoxMode.java +++ b/src/api/java/appeng/api/config/SearchBoxMode.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum SearchBoxMode { AUTOSEARCH, MANUAL_SEARCH, NEI_AUTOSEARCH, NEI_MANUAL_SEARCH diff --git a/src/api/java/appeng/api/config/SecurityPermissions.java b/src/api/java/appeng/api/config/SecurityPermissions.java index 48cb9f818..547fa39e7 100644 --- a/src/api/java/appeng/api/config/SecurityPermissions.java +++ b/src/api/java/appeng/api/config/SecurityPermissions.java @@ -23,6 +23,7 @@ package appeng.api.config; + /** * Represent the security systems basic permissions, these are not for anti-griefing, they are part of the mod as a * gameplay feature. diff --git a/src/api/java/appeng/api/config/SortDir.java b/src/api/java/appeng/api/config/SortDir.java index 12067e9fa..654fda0dc 100644 --- a/src/api/java/appeng/api/config/SortDir.java +++ b/src/api/java/appeng/api/config/SortDir.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum SortDir { ASCENDING, DESCENDING diff --git a/src/api/java/appeng/api/config/SortOrder.java b/src/api/java/appeng/api/config/SortOrder.java index 2a1e6f7e8..51cde4e64 100644 --- a/src/api/java/appeng/api/config/SortOrder.java +++ b/src/api/java/appeng/api/config/SortOrder.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum SortOrder { NAME, AMOUNT, MOD, INVTWEAKS diff --git a/src/api/java/appeng/api/config/StorageFilter.java b/src/api/java/appeng/api/config/StorageFilter.java index 407327f62..64f63f704 100644 --- a/src/api/java/appeng/api/config/StorageFilter.java +++ b/src/api/java/appeng/api/config/StorageFilter.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum StorageFilter { diff --git a/src/api/java/appeng/api/config/TerminalStyle.java b/src/api/java/appeng/api/config/TerminalStyle.java index 7465d9df6..d8687e1a3 100644 --- a/src/api/java/appeng/api/config/TerminalStyle.java +++ b/src/api/java/appeng/api/config/TerminalStyle.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum TerminalStyle { diff --git a/src/api/java/appeng/api/config/TunnelType.java b/src/api/java/appeng/api/config/TunnelType.java index 290b8230f..b42d28568 100644 --- a/src/api/java/appeng/api/config/TunnelType.java +++ b/src/api/java/appeng/api/config/TunnelType.java @@ -23,10 +23,10 @@ package appeng.api.config; + public enum TunnelType { ME, // Network Tunnel - BC_POWER, // MJ Tunnel IC2_POWER, // EU Tunnel RF_POWER, // RF Tunnel REDSTONE, // Redstone Tunnel diff --git a/src/api/java/appeng/api/config/Upgrades.java b/src/api/java/appeng/api/config/Upgrades.java index f808aedd4..0a585ee7a 100644 --- a/src/api/java/appeng/api/config/Upgrades.java +++ b/src/api/java/appeng/api/config/Upgrades.java @@ -25,9 +25,13 @@ package appeng.api.config; import java.util.HashMap; +import java.util.Map; import net.minecraft.item.ItemStack; +import com.google.common.base.Optional; + +import appeng.api.definitions.IItemDefinition; import appeng.api.util.AEItemDefinition; @@ -43,34 +47,74 @@ public enum Upgrades */ FUZZY( 1 ), SPEED( 1 ), INVERTER( 1 ); - public final int myTier; - public final HashMap supportedMax = new HashMap(); + /** + * @deprecated use {@link Upgrades#getTier()} + */ + @Deprecated + public final int tier; + + /** + * @deprecated use {@link Upgrades#getSupported()} + */ + @Deprecated + private final Map supportedMax = new HashMap(); Upgrades( int tier ) { - this.myTier = tier; + this.tier = tier; } /** * @return list of Items/Blocks that support this upgrade, and how many it supports. */ - public HashMap getSupported() + public Map getSupported() { return this.supportedMax; } - - - public void registerItem( AEItemDefinition myItem, int maxSupported ) + /** + * Registers a specific amount of this upgrade into a specific machine + * + * @param item machine in which this upgrade can be installed + * @param maxSupported amount how many upgrades can be installed + */ + public void registerItem( IItemDefinition item, int maxSupported ) { - if ( myItem != null ) + final Optional maybeStack = item.maybeStack( 1 ); + for ( ItemStack stack : maybeStack.asSet() ) { - final ItemStack stack = myItem.stack( 1 ); - this.registerItem( stack, maxSupported ); } } + /** + * Registers a specific amount of this upgrade into a specific machine + * + * @param item machine in which this upgrade can be installed + * @param maxSupported amount how many upgrades can be installed + * + * @deprecated use {@link Upgrades#registerItem(IItemDefinition, int)} + */ + @Deprecated + public void registerItem( AEItemDefinition item, int maxSupported ) + { + if ( item != null ) + { + final ItemStack stack = item.stack( 1 ); + + if ( stack != null ) + { + this.registerItem( stack, maxSupported ); + } + } + } + + /** + * Registers a specific amount of this upgrade into a specific machine + * + * @param stack machine in which this upgrade can be installed + * @param maxSupported amount how many upgrades can be installed + */ public void registerItem( ItemStack stack, int maxSupported ) { if ( stack != null ) @@ -78,4 +122,9 @@ public enum Upgrades this.supportedMax.put( stack, maxSupported ); } } + + public int getTier() + { + return this.tier; + } } diff --git a/src/api/java/appeng/api/config/ViewItems.java b/src/api/java/appeng/api/config/ViewItems.java index 929711be3..a87e0aa21 100644 --- a/src/api/java/appeng/api/config/ViewItems.java +++ b/src/api/java/appeng/api/config/ViewItems.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum ViewItems { ALL, STORED, CRAFTABLE diff --git a/src/api/java/appeng/api/config/YesNo.java b/src/api/java/appeng/api/config/YesNo.java index db68f80c8..c6bfcd602 100644 --- a/src/api/java/appeng/api/config/YesNo.java +++ b/src/api/java/appeng/api/config/YesNo.java @@ -23,6 +23,7 @@ package appeng.api.config; + public enum YesNo { YES, NO, UNDECIDED diff --git a/src/api/java/appeng/api/definitions/Blocks.java b/src/api/java/appeng/api/definitions/Blocks.java index 845388207..ec67d54e5 100644 --- a/src/api/java/appeng/api/definitions/Blocks.java +++ b/src/api/java/appeng/api/definitions/Blocks.java @@ -23,90 +23,109 @@ package appeng.api.definitions; + import appeng.api.util.AEItemDefinition; + +/** + * @deprecated use {@link IBlocks} now + */ +@Deprecated public class Blocks { - - /* - * World Gen - */ public AEItemDefinition blockQuartzOre; + public AEItemDefinition blockQuartzOreCharged; + public AEItemDefinition blockMatrixFrame; - /* - * Decorative - */ public AEItemDefinition blockQuartz; + public AEItemDefinition blockQuartzPillar; + public AEItemDefinition blockQuartzChiseled; + public AEItemDefinition blockQuartzGlass; + public AEItemDefinition blockQuartzVibrantGlass; + public AEItemDefinition blockQuartzTorch; + public AEItemDefinition blockFluix; + public AEItemDefinition blockSkyStone; + public AEItemDefinition blockSkyChest; + public AEItemDefinition blockSkyCompass; - /* - * Misc - */ public AEItemDefinition blockGrindStone; + public AEItemDefinition blockCrankHandle; + public AEItemDefinition blockInscriber; + public AEItemDefinition blockWireless; + public AEItemDefinition blockCharger; + public AEItemDefinition blockTinyTNT; + public AEItemDefinition blockSecurity; - /* - * Quantum Network Bridge - */ public AEItemDefinition blockQuantumRing; + public AEItemDefinition blockQuantumLink; - /* - * Spatial IO - */ public AEItemDefinition blockSpatialPylon; + public AEItemDefinition blockSpatialIOPort; - /* - * Bus / Cables - */ public AEItemDefinition blockMultiPart; - /* - * Machines - */ public AEItemDefinition blockController; + public AEItemDefinition blockDrive; + public AEItemDefinition blockChest; + public AEItemDefinition blockInterface; + public AEItemDefinition blockCellWorkbench; + public AEItemDefinition blockIOPort; + public AEItemDefinition blockCondenser; + public AEItemDefinition blockEnergyAcceptor; + public AEItemDefinition blockVibrationChamber; + public AEItemDefinition blockQuartzGrowthAccelerator; public AEItemDefinition blockEnergyCell; + public AEItemDefinition blockEnergyCellDense; + public AEItemDefinition blockEnergyCellCreative; - // rv1 public AEItemDefinition blockCraftingUnit; + public AEItemDefinition blockCraftingAccelerator; + public AEItemDefinition blockCraftingStorage1k; + public AEItemDefinition blockCraftingStorage4k; + public AEItemDefinition blockCraftingStorage16k; + public AEItemDefinition blockCraftingStorage64k; + public AEItemDefinition blockCraftingMonitor; public AEItemDefinition blockMolecularAssembler; public AEItemDefinition blockLightDetector; - public AEItemDefinition blockPaint; + public AEItemDefinition blockPaint; } diff --git a/src/api/java/appeng/api/definitions/IBlockDefinition.java b/src/api/java/appeng/api/definitions/IBlockDefinition.java new file mode 100644 index 000000000..7be25bc38 --- /dev/null +++ b/src/api/java/appeng/api/definitions/IBlockDefinition.java @@ -0,0 +1,21 @@ +package appeng.api.definitions; + + +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; + +import com.google.common.base.Optional; + + +public interface IBlockDefinition extends IItemDefinition +{ + /** + * @return the {@link Block} implementation if applicable + */ + Optional maybeBlock(); + + /** + * @return the {@link ItemBlock} implementation if applicable + */ + Optional maybeItemBlock(); +} diff --git a/src/api/java/appeng/api/definitions/IBlocks.java b/src/api/java/appeng/api/definitions/IBlocks.java new file mode 100644 index 000000000..d10ba5d29 --- /dev/null +++ b/src/api/java/appeng/api/definitions/IBlocks.java @@ -0,0 +1,164 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2013 AlgorithmX2 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package appeng.api.definitions; + + +/** + * A list of all blocks in AE + */ +public interface IBlocks +{ + /* + * world gen + */ + IBlockDefinition quartzOre(); + + IBlockDefinition quartzOreCharged(); + + IBlockDefinition matrixFrame(); + + /* + * decorative + */ + IBlockDefinition quartz(); + + IBlockDefinition quartzPillar(); + + IBlockDefinition quartzChiseled(); + + IBlockDefinition quartzGlass(); + + IBlockDefinition quartzVibrantGlass(); + + IBlockDefinition quartzTorch(); + + IBlockDefinition fluix(); + + IBlockDefinition skyStone(); + + IBlockDefinition skyChest(); + + IBlockDefinition skyCompass(); + + IBlockDefinition skyStoneStair(); + + IBlockDefinition skyStoneBlockStair(); + + IBlockDefinition skyStoneBrickStair(); + + IBlockDefinition skyStoneSmallBrickStair(); + + IBlockDefinition fluixStair(); + + IBlockDefinition quartzStair(); + + IBlockDefinition chiseledQuartzStair(); + + IBlockDefinition quartzPillarStair(); + + /* + * misc + */ + ITileDefinition grindStone(); + + ITileDefinition crankHandle(); + + ITileDefinition inscriber(); + + ITileDefinition wireless(); + + ITileDefinition charger(); + + ITileDefinition tinyTNT(); + + ITileDefinition security(); + + /* + * quantum Network Bridge + */ + ITileDefinition quantumRing(); + + ITileDefinition quantumLink(); + + /* + * spatial iO + */ + ITileDefinition spatialPylon(); + + ITileDefinition spatialIOPort(); + + /* + * Bus / cables + */ + ITileDefinition multiPart(); + + /* + * machines + */ + ITileDefinition controller(); + + ITileDefinition drive(); + + ITileDefinition chest(); + + ITileDefinition iface(); + + ITileDefinition cellWorkbench(); + + ITileDefinition iOPort(); + + ITileDefinition condenser(); + + ITileDefinition energyAcceptor(); + + ITileDefinition vibrationChamber(); + + ITileDefinition quartzGrowthAccelerator(); + + ITileDefinition energyCell(); + + ITileDefinition energyCellDense(); + + ITileDefinition energyCellCreative(); + + // rv1 + ITileDefinition craftingUnit(); + + ITileDefinition craftingAccelerator(); + + ITileDefinition craftingStorage1k(); + + ITileDefinition craftingStorage4k(); + + ITileDefinition craftingStorage16k(); + + ITileDefinition craftingStorage64k(); + + ITileDefinition craftingMonitor(); + + ITileDefinition molecularAssembler(); + + ITileDefinition lightDetector(); + + ITileDefinition paint(); +} diff --git a/src/api/java/appeng/api/definitions/IComparableDefinition.java b/src/api/java/appeng/api/definitions/IComparableDefinition.java new file mode 100644 index 000000000..f98d028ed --- /dev/null +++ b/src/api/java/appeng/api/definitions/IComparableDefinition.java @@ -0,0 +1,32 @@ +package appeng.api.definitions; + + +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; + + +/** + * Interface to compare a definition with an itemstack or a block + */ +public interface IComparableDefinition +{ + /** + * Compare {@link ItemStack} with this + * + * @param comparableStack compared item + * @return true if the item stack is a matching item. + */ + boolean isSameAs( ItemStack comparableStack ); + + /** + * Compare Block with world. + * + * @param world world of block + * @param x x pos of block + * @param y y pos of block + * @param z z pos of block + * + * @return if the block is placed in the world at the specific location. + */ + boolean isSameAs( IBlockAccess world, int x, int y, int z ); +} diff --git a/src/api/java/appeng/api/definitions/IDefinitions.java b/src/api/java/appeng/api/definitions/IDefinitions.java new file mode 100644 index 000000000..0f6a30da7 --- /dev/null +++ b/src/api/java/appeng/api/definitions/IDefinitions.java @@ -0,0 +1,50 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2013 AlgorithmX2 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package appeng.api.definitions; + + +/** + * All definitions in AE + */ +public interface IDefinitions +{ + /** + * @return an accessible list of all of AE's blocks + */ + IBlocks blocks(); + + /** + * @return an accessible list of all of AE's Items + */ + IItems items(); + + /** + * @return an accessible list of all of AE's materials; materials are items + */ + IMaterials materials(); + + /** + * @return an accessible list of all of AE's parts, parts are items + */ + IParts parts(); +} diff --git a/src/api/java/appeng/api/definitions/IItemDefinition.java b/src/api/java/appeng/api/definitions/IItemDefinition.java new file mode 100644 index 000000000..c1d8e324a --- /dev/null +++ b/src/api/java/appeng/api/definitions/IItemDefinition.java @@ -0,0 +1,21 @@ +package appeng.api.definitions; + + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import com.google.common.base.Optional; + + +public interface IItemDefinition extends IComparableDefinition +{ + /** + * @return the {@link Item} Implementation if applicable + */ + Optional maybeItem(); + + /** + * @return an {@link ItemStack} with specified quantity of this item. + */ + Optional maybeStack(int stackSize); +} diff --git a/src/api/java/appeng/api/definitions/IItems.java b/src/api/java/appeng/api/definitions/IItems.java new file mode 100644 index 000000000..179cee8e1 --- /dev/null +++ b/src/api/java/appeng/api/definitions/IItems.java @@ -0,0 +1,108 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2013 AlgorithmX2 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package appeng.api.definitions; + + +import appeng.api.util.AEColoredItemDefinition; + + +/** + * A list of all items in AE + */ +public interface IItems +{ + IItemDefinition certusQuartzAxe(); + + IItemDefinition certusQuartzHoe(); + + IItemDefinition certusQuartzShovel(); + + IItemDefinition certusQuartzPick(); + + IItemDefinition certusQuartzSword(); + + IItemDefinition certusQuartzWrench(); + + IItemDefinition certusQuartzKnife(); + + IItemDefinition netherQuartzAxe(); + + IItemDefinition netherQuartzHoe(); + + IItemDefinition netherQuartzShovel(); + + IItemDefinition netherQuartzPick(); + + IItemDefinition netherQuartzSword(); + + IItemDefinition netherQuartzWrench(); + + IItemDefinition netherQuartzKnife(); + + IItemDefinition entropyManipulator(); + + IItemDefinition wirelessTerminal(); + + IItemDefinition biometricCard(); + + IItemDefinition chargedStaff(); + + IItemDefinition massCannon(); + + IItemDefinition memoryCard(); + + IItemDefinition networkTool(); + + IItemDefinition portableCell(); + + IItemDefinition cellCreative(); + + IItemDefinition viewCell(); + + IItemDefinition cell1k(); + + IItemDefinition cell4k(); + + IItemDefinition cell16k(); + + IItemDefinition cell64k(); + + IItemDefinition spatialCell2(); + + IItemDefinition spatialCell16(); + + IItemDefinition spatialCell128(); + + IItemDefinition facade(); + + IItemDefinition crystalSeed(); + + // rv1 + IItemDefinition encodedPattern(); + + IItemDefinition colorApplicator(); + + AEColoredItemDefinition coloredPaintBall(); + + AEColoredItemDefinition coloredLumenPaintBall(); +} diff --git a/src/api/java/appeng/api/definitions/IMaterials.java b/src/api/java/appeng/api/definitions/IMaterials.java new file mode 100644 index 000000000..dbb0ad645 --- /dev/null +++ b/src/api/java/appeng/api/definitions/IMaterials.java @@ -0,0 +1,138 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2013 AlgorithmX2 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package appeng.api.definitions; + + +/** + * A list of all materials in AE + */ +public interface IMaterials +{ + IItemDefinition cell2SpatialPart(); + + IItemDefinition cell16SpatialPart(); + + IItemDefinition cell128SpatialPart(); + + IItemDefinition silicon(); + + IItemDefinition skyDust(); + + IItemDefinition calcProcessorPress(); + + IItemDefinition engProcessorPress(); + + IItemDefinition logicProcessorPress(); + + IItemDefinition calcProcessorPrint(); + + IItemDefinition engProcessorPrint(); + + IItemDefinition logicProcessorPrint(); + + IItemDefinition siliconPress(); + + IItemDefinition siliconPrint(); + + IItemDefinition namePress(); + + IItemDefinition logicProcessor(); + + IItemDefinition calcProcessor(); + + IItemDefinition engProcessor(); + + IItemDefinition basicCard(); + + IItemDefinition advCard(); + + IItemDefinition purifiedCertusQuartzCrystal(); + + IItemDefinition purifiedNetherQuartzCrystal(); + + IItemDefinition purifiedFluixCrystal(); + + IItemDefinition cell1kPart(); + + IItemDefinition cell4kPart(); + + IItemDefinition cell16kPart(); + + IItemDefinition cell64kPart(); + + IItemDefinition emptyStorageCell(); + + IItemDefinition cardRedstone(); + + IItemDefinition cardSpeed(); + + IItemDefinition cardCapacity(); + + IItemDefinition cardFuzzy(); + + IItemDefinition cardInverter(); + + IItemDefinition cardCrafting(); + + IItemDefinition enderDust(); + + IItemDefinition flour(); + + IItemDefinition goldDust(); + + IItemDefinition ironDust(); + + IItemDefinition fluixDust(); + + IItemDefinition certusQuartzDust(); + + IItemDefinition netherQuartzDust(); + + IItemDefinition matterBall(); + + IItemDefinition ironNugget(); + + IItemDefinition certusQuartzCrystal(); + + IItemDefinition certusQuartzCrystalCharged(); + + IItemDefinition fluixCrystal(); + + IItemDefinition fluixPearl(); + + IItemDefinition woodenGear(); + + IItemDefinition wireless(); + + IItemDefinition wirelessBooster(); + + IItemDefinition annihilationCore(); + + IItemDefinition formationCore(); + + IItemDefinition singularity(); + + IItemDefinition qESingularity(); + + IItemDefinition blankPattern(); +} diff --git a/src/api/java/appeng/api/definitions/IParts.java b/src/api/java/appeng/api/definitions/IParts.java new file mode 100644 index 000000000..f79cf3e09 --- /dev/null +++ b/src/api/java/appeng/api/definitions/IParts.java @@ -0,0 +1,104 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2013 AlgorithmX2 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package appeng.api.definitions; + + +import appeng.api.util.AEColoredItemDefinition; + + +/** + * A list of all parts in AE + */ +public interface IParts +{ + AEColoredItemDefinition cableSmart(); + + AEColoredItemDefinition cableCovered(); + + AEColoredItemDefinition cableGlass(); + + AEColoredItemDefinition cableDense(); + + AEColoredItemDefinition lumenCableSmart(); + + AEColoredItemDefinition lumenCableCovered(); + + AEColoredItemDefinition lumenCableGlass(); + + AEColoredItemDefinition lumenCableDense(); + + IItemDefinition quartzFiber(); + + IItemDefinition toggleBus(); + + IItemDefinition invertedToggleBus(); + + IItemDefinition storageBus(); + + IItemDefinition importBus(); + + IItemDefinition exportBus(); + + IItemDefinition iface(); + + IItemDefinition levelEmitter(); + + IItemDefinition annihilationPlane(); + + IItemDefinition formationPlane(); + + IItemDefinition p2PTunnelME(); + + IItemDefinition p2PTunnelRedstone(); + + IItemDefinition p2PTunnelItems(); + + IItemDefinition p2PTunnelLiquids(); + + IItemDefinition p2PTunnelEU(); + + IItemDefinition p2PTunnelRF(); + + IItemDefinition p2PTunnelLight(); + + IItemDefinition cableAnchor(); + + IItemDefinition monitor(); + + IItemDefinition semiDarkMonitor(); + + IItemDefinition darkMonitor(); + + IItemDefinition interfaceTerminal(); + + IItemDefinition patternTerminal(); + + IItemDefinition craftingTerminal(); + + IItemDefinition terminal(); + + IItemDefinition storageMonitor(); + + IItemDefinition conversionMonitor(); +} diff --git a/src/api/java/appeng/api/definitions/ITileDefinition.java b/src/api/java/appeng/api/definitions/ITileDefinition.java new file mode 100644 index 000000000..89f9641dd --- /dev/null +++ b/src/api/java/appeng/api/definitions/ITileDefinition.java @@ -0,0 +1,15 @@ +package appeng.api.definitions; + + +import net.minecraft.tileentity.TileEntity; + +import com.google.common.base.Optional; + + +public interface ITileDefinition extends IBlockDefinition +{ + /** + * @return the {@link TileEntity} Class if applicable. + */ + Optional> maybeEntity(); +} diff --git a/src/api/java/appeng/api/definitions/Items.java b/src/api/java/appeng/api/definitions/Items.java index 31d62635b..09c242629 100644 --- a/src/api/java/appeng/api/definitions/Items.java +++ b/src/api/java/appeng/api/definitions/Items.java @@ -23,55 +23,88 @@ package appeng.api.definitions; + import appeng.api.util.AEColoredItemDefinition; import appeng.api.util.AEItemDefinition; + +/** + * @deprecated use {@link IItems} + */ +@Deprecated public class Items { - public AEItemDefinition itemCertusQuartzAxe; + public AEItemDefinition itemCertusQuartzHoe; + public AEItemDefinition itemCertusQuartzShovel; + public AEItemDefinition itemCertusQuartzPick; + public AEItemDefinition itemCertusQuartzSword; + public AEItemDefinition itemCertusQuartzWrench; + public AEItemDefinition itemCertusQuartzKnife; public AEItemDefinition itemNetherQuartzAxe; + public AEItemDefinition itemNetherQuartzHoe; + public AEItemDefinition itemNetherQuartzShovel; + public AEItemDefinition itemNetherQuartzPick; + public AEItemDefinition itemNetherQuartzSword; + public AEItemDefinition itemNetherQuartzWrench; + public AEItemDefinition itemNetherQuartzKnife; public AEItemDefinition itemEntropyManipulator; + public AEItemDefinition itemWirelessTerminal; + public AEItemDefinition itemBiometricCard; + public AEItemDefinition itemChargedStaff; + public AEItemDefinition itemMassCannon; + public AEItemDefinition itemMemoryCard; + public AEItemDefinition itemNetworkTool; + public AEItemDefinition itemPortableCell; public AEItemDefinition itemCellCreative; + public AEItemDefinition itemViewCell; public AEItemDefinition itemCell1k; + public AEItemDefinition itemCell4k; + public AEItemDefinition itemCell16k; + public AEItemDefinition itemCell64k; public AEItemDefinition itemSpatialCell2; + public AEItemDefinition itemSpatialCell16; + public AEItemDefinition itemSpatialCell128; public AEItemDefinition itemFacade; + public AEItemDefinition itemCrystalSeed; - // rv1 public AEItemDefinition itemEncodedPattern; + public AEItemDefinition itemColorApplicator; + public AEColoredItemDefinition itemPaintBall; + public AEColoredItemDefinition itemLumenPaintBall; } diff --git a/src/api/java/appeng/api/definitions/Materials.java b/src/api/java/appeng/api/definitions/Materials.java index bf281bdaa..886964742 100644 --- a/src/api/java/appeng/api/definitions/Materials.java +++ b/src/api/java/appeng/api/definitions/Materials.java @@ -23,81 +23,121 @@ package appeng.api.definitions; + import appeng.api.util.AEItemDefinition; + +/** + * @deprecated use {@link IMaterials} + */ +@Deprecated public class Materials { - public AEItemDefinition materialCell2SpatialPart; + public AEItemDefinition materialCell16SpatialPart; + public AEItemDefinition materialCell128SpatialPart; public AEItemDefinition materialSilicon; + public AEItemDefinition materialSkyDust; public AEItemDefinition materialCalcProcessorPress; + public AEItemDefinition materialEngProcessorPress; + public AEItemDefinition materialLogicProcessorPress; public AEItemDefinition materialCalcProcessorPrint; + public AEItemDefinition materialEngProcessorPrint; + public AEItemDefinition materialLogicProcessorPrint; public AEItemDefinition materialSiliconPress; + public AEItemDefinition materialSiliconPrint; public AEItemDefinition materialNamePress; public AEItemDefinition materialLogicProcessor; + public AEItemDefinition materialCalcProcessor; + public AEItemDefinition materialEngProcessor; public AEItemDefinition materialBasicCard; + public AEItemDefinition materialAdvCard; public AEItemDefinition materialPurifiedCertusQuartzCrystal; + public AEItemDefinition materialPurifiedNetherQuartzCrystal; + public AEItemDefinition materialPurifiedFluixCrystal; public AEItemDefinition materialCell1kPart; + public AEItemDefinition materialCell4kPart; + public AEItemDefinition materialCell16kPart; + public AEItemDefinition materialCell64kPart; + public AEItemDefinition materialEmptyStorageCell; public AEItemDefinition materialCardRedstone; + public AEItemDefinition materialCardSpeed; + public AEItemDefinition materialCardCapacity; + public AEItemDefinition materialCardFuzzy; + public AEItemDefinition materialCardInverter; + public AEItemDefinition materialCardCrafting; public AEItemDefinition materialEnderDust; + public AEItemDefinition materialFlour; + public AEItemDefinition materialGoldDust; + public AEItemDefinition materialIronDust; + public AEItemDefinition materialFluixDust; + public AEItemDefinition materialCertusQuartzDust; + public AEItemDefinition materialNetherQuartzDust; public AEItemDefinition materialMatterBall; + public AEItemDefinition materialIronNugget; public AEItemDefinition materialCertusQuartzCrystal; + public AEItemDefinition materialCertusQuartzCrystalCharged; + public AEItemDefinition materialFluixCrystal; + public AEItemDefinition materialFluixPearl; public AEItemDefinition materialWoodenGear; public AEItemDefinition materialWireless; + public AEItemDefinition materialWirelessBooster; public AEItemDefinition materialAnnihilationCore; + public AEItemDefinition materialFormationCore; public AEItemDefinition materialSingularity; - public AEItemDefinition materialQESingularity; - public AEItemDefinition materialBlankPattern; + public AEItemDefinition materialQESingularity; + + public AEItemDefinition materialBlankPattern; } diff --git a/src/api/java/appeng/api/definitions/Parts.java b/src/api/java/appeng/api/definitions/Parts.java index 828356adf..1d728a35e 100644 --- a/src/api/java/appeng/api/definitions/Parts.java +++ b/src/api/java/appeng/api/definitions/Parts.java @@ -23,54 +23,84 @@ package appeng.api.definitions; + import appeng.api.util.AEColoredItemDefinition; import appeng.api.util.AEItemDefinition; + +/** + * @deprecated use {@link IParts} + */ +@Deprecated public class Parts { - public AEColoredItemDefinition partCableSmart; + public AEColoredItemDefinition partCableCovered; + public AEColoredItemDefinition partCableGlass; + public AEColoredItemDefinition partCableDense; public AEColoredItemDefinition partLumenCableSmart; + public AEColoredItemDefinition partLumenCableCovered; + public AEColoredItemDefinition partLumenCableGlass; + public AEColoredItemDefinition partLumenCableDense; public AEItemDefinition partQuartzFiber; + public AEItemDefinition partToggleBus; + public AEItemDefinition partInvertedToggleBus; public AEItemDefinition partStorageBus; + public AEItemDefinition partImportBus; + public AEItemDefinition partExportBus; + public AEItemDefinition partInterface; public AEItemDefinition partLevelEmitter; public AEItemDefinition partAnnihilationPlane; + public AEItemDefinition partFormationPlane; public AEItemDefinition partP2PTunnelME; + public AEItemDefinition partP2PTunnelRedstone; + public AEItemDefinition partP2PTunnelItems; + public AEItemDefinition partP2PTunnelLiquids; - public AEItemDefinition partP2PTunnelMJ; + public AEItemDefinition partP2PTunnelEU; + public AEItemDefinition partP2PTunnelRF; + public AEItemDefinition partP2PTunnelLight; public AEItemDefinition partCableAnchor; + public AEItemDefinition partMonitor; + public AEItemDefinition partSemiDarkMonitor; + public AEItemDefinition partDarkMonitor; public AEItemDefinition partInterfaceTerminal; + public AEItemDefinition partPatternTerminal; + public AEItemDefinition partCraftingTerminal; + public AEItemDefinition partTerminal; + public AEItemDefinition partStorageMonitor; + public AEItemDefinition partConversionMonitor; } diff --git a/src/api/java/appeng/api/events/LocatableEventAnnounce.java b/src/api/java/appeng/api/events/LocatableEventAnnounce.java index 1c3983912..da3496928 100644 --- a/src/api/java/appeng/api/events/LocatableEventAnnounce.java +++ b/src/api/java/appeng/api/events/LocatableEventAnnounce.java @@ -23,12 +23,15 @@ package appeng.api.events; -import appeng.api.features.ILocatable; + import cpw.mods.fml.common.eventhandler.Event; +import appeng.api.features.ILocatable; + + /** * Input Event: - * + * * Used to Notify the Location Registry of objects, and their availability. */ public class LocatableEventAnnounce extends Event @@ -40,12 +43,13 @@ public class LocatableEventAnnounce extends Event Unregister // Removes the locatable from the registry } + final public ILocatable target; final public LocatableEvent change; - public LocatableEventAnnounce(ILocatable o, LocatableEvent ev) { + public LocatableEventAnnounce( ILocatable o, LocatableEvent ev ) + { this.target = o; this.change = ev; } - } diff --git a/src/api/java/appeng/api/exceptions/AppEngException.java b/src/api/java/appeng/api/exceptions/AppEngException.java index 771566476..9734437fe 100644 --- a/src/api/java/appeng/api/exceptions/AppEngException.java +++ b/src/api/java/appeng/api/exceptions/AppEngException.java @@ -23,12 +23,14 @@ package appeng.api.exceptions; + public class AppEngException extends Exception { private static final long serialVersionUID = -9051434206368465494L; - public AppEngException(String t) { + public AppEngException( String t ) + { super( t ); } } diff --git a/src/api/java/appeng/api/exceptions/CouldNotAccessCoreAPI.java b/src/api/java/appeng/api/exceptions/CouldNotAccessCoreAPI.java new file mode 100644 index 000000000..7003f5143 --- /dev/null +++ b/src/api/java/appeng/api/exceptions/CouldNotAccessCoreAPI.java @@ -0,0 +1,10 @@ +package appeng.api.exceptions; + + +public class CouldNotAccessCoreAPI extends RuntimeException +{ + public CouldNotAccessCoreAPI( String message ) + { + super( message ); + } +} diff --git a/src/api/java/appeng/api/exceptions/FailedConnection.java b/src/api/java/appeng/api/exceptions/FailedConnection.java index df8beb579..086cea5a3 100644 --- a/src/api/java/appeng/api/exceptions/FailedConnection.java +++ b/src/api/java/appeng/api/exceptions/FailedConnection.java @@ -23,11 +23,13 @@ package appeng.api.exceptions; + public class FailedConnection extends Exception { private static final long serialVersionUID = -2544208090248293753L; - public FailedConnection() { + public FailedConnection() + { } } diff --git a/src/api/java/appeng/api/exceptions/MissingDefinition.java b/src/api/java/appeng/api/exceptions/MissingDefinition.java new file mode 100644 index 000000000..09e053736 --- /dev/null +++ b/src/api/java/appeng/api/exceptions/MissingDefinition.java @@ -0,0 +1,10 @@ +package appeng.api.exceptions; + + +public class MissingDefinition extends RuntimeException +{ + public MissingDefinition( String message ) + { + super( message ); + } +} diff --git a/src/api/java/appeng/api/exceptions/MissingIngredientError.java b/src/api/java/appeng/api/exceptions/MissingIngredientError.java index 936d48499..842747a02 100644 --- a/src/api/java/appeng/api/exceptions/MissingIngredientError.java +++ b/src/api/java/appeng/api/exceptions/MissingIngredientError.java @@ -23,12 +23,14 @@ package appeng.api.exceptions; -public class MissingIngredientError extends Exception { + +public class MissingIngredientError extends Exception +{ private static final long serialVersionUID = -998858343831371697L; - public MissingIngredientError(String n) { + public MissingIngredientError( String n ) + { super( n ); } - } diff --git a/src/api/java/appeng/api/exceptions/ModNotInstalled.java b/src/api/java/appeng/api/exceptions/ModNotInstalled.java index 837b44dd1..6f7bfa9bb 100644 --- a/src/api/java/appeng/api/exceptions/ModNotInstalled.java +++ b/src/api/java/appeng/api/exceptions/ModNotInstalled.java @@ -23,13 +23,14 @@ package appeng.api.exceptions; + public class ModNotInstalled extends Exception { private static final long serialVersionUID = -9052435206368425494L; - public ModNotInstalled(String t) { + public ModNotInstalled( String t ) + { super( t ); } - } diff --git a/src/api/java/appeng/api/exceptions/RecipeError.java b/src/api/java/appeng/api/exceptions/RecipeError.java index cbc1ec6b8..1973f348f 100644 --- a/src/api/java/appeng/api/exceptions/RecipeError.java +++ b/src/api/java/appeng/api/exceptions/RecipeError.java @@ -23,13 +23,14 @@ package appeng.api.exceptions; + public class RecipeError extends Exception { private static final long serialVersionUID = -6602870588617670262L; - public RecipeError(String n) { + public RecipeError( String n ) + { super( n ); } - } diff --git a/src/api/java/appeng/api/exceptions/RegistrationError.java b/src/api/java/appeng/api/exceptions/RegistrationError.java index 77615a49f..f3d2bdd00 100644 --- a/src/api/java/appeng/api/exceptions/RegistrationError.java +++ b/src/api/java/appeng/api/exceptions/RegistrationError.java @@ -23,13 +23,14 @@ package appeng.api.exceptions; + public class RegistrationError extends Exception { private static final long serialVersionUID = -6602870588617670263L; - public RegistrationError(String n) { + public RegistrationError( String n ) + { super( n ); } - } diff --git a/src/api/java/appeng/api/features/IGrinderEntry.java b/src/api/java/appeng/api/features/IGrinderEntry.java index 5efe2864c..4b1df507a 100644 --- a/src/api/java/appeng/api/features/IGrinderEntry.java +++ b/src/api/java/appeng/api/features/IGrinderEntry.java @@ -23,8 +23,10 @@ package appeng.api.features; + import net.minecraft.item.ItemStack; + /** * Registration Records for {@link IGrinderRegistry} */ diff --git a/src/api/java/appeng/api/features/IGrinderRegistry.java b/src/api/java/appeng/api/features/IGrinderRegistry.java index 5ae3bd9e4..6b25cfa57 100644 --- a/src/api/java/appeng/api/features/IGrinderRegistry.java +++ b/src/api/java/appeng/api/features/IGrinderRegistry.java @@ -28,6 +28,7 @@ import java.util.List; import net.minecraft.item.ItemStack; + /** * Lets you manipulate Grinder Recipes, by adding or editing existing ones. */ @@ -56,30 +57,30 @@ public interface IGrinderRegistry * @param in input * @param out output * @param optional optional output - * @param chance chance to get the optional output within 0.0 - 1.0 - * @param turns amount of turns to turn the input into the outputs + * @param chance chance to get the optional output within 0.0 - 1.0 + * @param turns amount of turns to turn the input into the outputs */ - void addRecipe(ItemStack in, ItemStack out, ItemStack optional, float chance, int turns); + void addRecipe( ItemStack in, ItemStack out, ItemStack optional, float chance, int turns ); /** * add a new recipe with optional outputs, duplicates will not be added. - * + * * @param in input * @param out output * @param optional optional output * @param chance chance to get the optional output within 0.0 - 1.0 * @param optional2 second optional output - * @param chance2 chance to get the second optional output within 0.0 - 1.0 - * @param turns amount of turns to turn the input into the outputs + * @param chance2 chance to get the second optional output within 0.0 - 1.0 + * @param turns amount of turns to turn the input into the outputs */ - void addRecipe(ItemStack in, ItemStack out, ItemStack optional, float chance, ItemStack optional2, float chance2, int turns); + void addRecipe( ItemStack in, ItemStack out, ItemStack optional, float chance, ItemStack optional2, float chance2, int turns ); /** * Searches for a recipe for a given input, and returns it. * * @param input input + * * @return identified recipe or null */ IGrinderEntry getRecipeForInput( ItemStack input ); - } diff --git a/src/api/java/appeng/api/features/IItemComparison.java b/src/api/java/appeng/api/features/IItemComparison.java index 9b62fd339..b7d2b982b 100644 --- a/src/api/java/appeng/api/features/IItemComparison.java +++ b/src/api/java/appeng/api/features/IItemComparison.java @@ -23,11 +23,10 @@ package appeng.api.features; + public interface IItemComparison { - boolean sameAsPrecise( IItemComparison comp ); boolean sameAsFuzzy( IItemComparison comp ); - } diff --git a/src/api/java/appeng/api/features/IItemComparisonProvider.java b/src/api/java/appeng/api/features/IItemComparisonProvider.java index f0f28c7c8..c432c0baf 100644 --- a/src/api/java/appeng/api/features/IItemComparisonProvider.java +++ b/src/api/java/appeng/api/features/IItemComparisonProvider.java @@ -23,8 +23,10 @@ package appeng.api.features; + 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 @@ -38,16 +40,17 @@ public interface IItemComparisonProvider * the supplied item. * * @param is item + * * @return IItemComparison, or null */ - IItemComparison getComparison(ItemStack is); + IItemComparison getComparison( ItemStack is ); /** * Simple test for support ( AE generally skips this and calls the above function. ) * * @param stack item + * * @return true, if getComparison will return a valid IItemComparison Object */ boolean canHandle( ItemStack stack ); - } \ No newline at end of file diff --git a/src/api/java/appeng/api/features/ILocatable.java b/src/api/java/appeng/api/features/ILocatable.java index ae0e2faa6..c64a937fc 100644 --- a/src/api/java/appeng/api/features/ILocatable.java +++ b/src/api/java/appeng/api/features/ILocatable.java @@ -23,8 +23,10 @@ package appeng.api.features; + import appeng.api.events.LocatableEventAnnounce; + /** * A registration record for the {@link ILocatableRegistry} use the {@link LocatableEventAnnounce} event on the Forge * Event bus to update the registry. @@ -36,5 +38,4 @@ public interface ILocatable * @return the serial for a locatable object */ long getLocatableSerial(); - } \ No newline at end of file diff --git a/src/api/java/appeng/api/features/IMatterCannonAmmoRegistry.java b/src/api/java/appeng/api/features/IMatterCannonAmmoRegistry.java index 430d6351c..c8939174b 100644 --- a/src/api/java/appeng/api/features/IMatterCannonAmmoRegistry.java +++ b/src/api/java/appeng/api/features/IMatterCannonAmmoRegistry.java @@ -23,25 +23,27 @@ package appeng.api.features; + import net.minecraft.item.ItemStack; + public interface IMatterCannonAmmoRegistry { /** * register a new ammo, generally speaking this is based off of atomic weight to make it easier to guess at - * + * * @param ammo new ammo * @param weight atomic weight */ - void registerAmmo(ItemStack ammo, double weight); + void registerAmmo( ItemStack ammo, double weight ); /** * get the penetration value for a particular ammo, 0 indicates a non-ammo. * * @param is ammo + * * @return 0 or a valid penetration value. */ - float getPenetration(ItemStack is); - + float getPenetration( ItemStack is ); } diff --git a/src/api/java/appeng/api/features/INetworkEncodable.java b/src/api/java/appeng/api/features/INetworkEncodable.java index 4b09bab77..f7046a02b 100644 --- a/src/api/java/appeng/api/features/INetworkEncodable.java +++ b/src/api/java/appeng/api/features/INetworkEncodable.java @@ -23,21 +23,25 @@ package appeng.api.features; + import net.minecraft.item.ItemStack; -public interface INetworkEncodable { + +public interface INetworkEncodable +{ /** * Used to get the current key from the item. * * @param item item + * * @return string key of item */ - String getEncryptionKey(ItemStack item); + String getEncryptionKey( ItemStack item ); /** * Encode the wireless frequency via the Controller. - * + * * @param item * the wireless terminal. * @param encKey @@ -45,6 +49,5 @@ public interface INetworkEncodable { * @param name * null for now. */ - void setEncryptionKey(ItemStack item, String encKey, String name); - + void setEncryptionKey( ItemStack item, String encKey, String name ); } diff --git a/src/api/java/appeng/api/features/IP2PTunnelRegistry.java b/src/api/java/appeng/api/features/IP2PTunnelRegistry.java index 5958b463a..198ad48c1 100644 --- a/src/api/java/appeng/api/features/IP2PTunnelRegistry.java +++ b/src/api/java/appeng/api/features/IP2PTunnelRegistry.java @@ -28,6 +28,7 @@ import net.minecraft.item.ItemStack; import appeng.api.config.TunnelType; + /** * A Registry for how p2p Tunnels are attuned */ @@ -37,7 +38,7 @@ public interface IP2PTunnelRegistry /** * Allows third parties to register items from their mod as potential * attunements for AE's P2P Tunnels - * + * * @param trigger * - the item which triggers attunement * @param type @@ -49,8 +50,8 @@ public interface IP2PTunnelRegistry * returns null if no attunement can be found. * * @param trigger attunement trigger + * * @return null if no attunement can be found or attunement */ - TunnelType getTunnelTypeByItem(ItemStack trigger); - + TunnelType getTunnelTypeByItem( ItemStack trigger ); } \ No newline at end of file diff --git a/src/api/java/appeng/api/features/IPlayerRegistry.java b/src/api/java/appeng/api/features/IPlayerRegistry.java index b1b5770d8..54cbc8f5e 100644 --- a/src/api/java/appeng/api/features/IPlayerRegistry.java +++ b/src/api/java/appeng/api/features/IPlayerRegistry.java @@ -23,10 +23,12 @@ package appeng.api.features; + import net.minecraft.entity.player.EntityPlayer; import com.mojang.authlib.GameProfile; + /** * Maintains a save specific list of userids and username combinations this greatly simplifies storage internally and * gives a common place to look up and get IDs for the security framework. @@ -36,20 +38,22 @@ public interface IPlayerRegistry /** * @param gameProfile user game profile + * * @return user id of a username. */ - int getID(GameProfile gameProfile); + int getID( GameProfile gameProfile ); /** * @param player player + * * @return user id of a player entity. */ - int getID(EntityPlayer player); + int getID( EntityPlayer player ); /** * @param playerID to be found player id + * * @return PlayerEntity, or null if the player could not be found. */ - EntityPlayer findPlayer(int playerID); - + EntityPlayer findPlayer( int playerID ); } diff --git a/src/api/java/appeng/api/features/IRecipeHandlerRegistry.java b/src/api/java/appeng/api/features/IRecipeHandlerRegistry.java index f0edb9e7f..6b2d9f2bf 100644 --- a/src/api/java/appeng/api/features/IRecipeHandlerRegistry.java +++ b/src/api/java/appeng/api/features/IRecipeHandlerRegistry.java @@ -23,37 +23,40 @@ package appeng.api.features; + import appeng.api.recipes.ICraftHandler; import appeng.api.recipes.IRecipeHandler; import appeng.api.recipes.ISubItemResolver; + public interface IRecipeHandlerRegistry { /** * Add a new Recipe Handler to the parser. - * + * * MUST BE CALLED IN PRE-INIT - * + * * @param name name of crafthandler * @param handler class of crafthandler */ - void addNewCraftHandler(String name, Class handler); + void addNewCraftHandler( String name, Class handler ); /** * Add a new resolver to the parser. - * + * * MUST BE CALLED IN PRE-INIT * * @param sir sub item resolver */ - void addNewSubItemResolver(ISubItemResolver sir); + void addNewSubItemResolver( ISubItemResolver sir ); /** * @param name name of crafting handler + * * @return A recipe handler by name, returns null on failure. */ - ICraftHandler getCraftHandlerFor(String name); + ICraftHandler getCraftHandlerFor( String name ); /** * @return a new recipe handler, which can be used to parse, and read recipe files. @@ -64,9 +67,9 @@ public interface IRecipeHandlerRegistry * resolve sub items by name. * * @param nameSpace namespace of item - * @param itemName full name of item + * @param itemName full name of item + * * @return ResolverResult or ResolverResultSet */ - Object resolveItem(String nameSpace, String itemName); - + Object resolveItem( String nameSpace, String itemName ); } diff --git a/src/api/java/appeng/api/features/IRegistryContainer.java b/src/api/java/appeng/api/features/IRegistryContainer.java index c367d2712..19f1607c8 100644 --- a/src/api/java/appeng/api/features/IRegistryContainer.java +++ b/src/api/java/appeng/api/features/IRegistryContainer.java @@ -23,11 +23,13 @@ package appeng.api.features; + import appeng.api.movable.IMovableRegistry; import appeng.api.networking.IGridCacheRegistry; import appeng.api.storage.ICellRegistry; import appeng.api.storage.IExternalStorageRegistry; + public interface IRegistryContainer { diff --git a/src/api/java/appeng/api/features/ISpecialComparisonRegistry.java b/src/api/java/appeng/api/features/ISpecialComparisonRegistry.java index bd2e02f48..c55bf1757 100644 --- a/src/api/java/appeng/api/features/ISpecialComparisonRegistry.java +++ b/src/api/java/appeng/api/features/ISpecialComparisonRegistry.java @@ -23,11 +23,12 @@ package appeng.api.features; + import net.minecraft.item.ItemStack; + /** * A Registry of any special comparison handlers for AE To use. - * */ public interface ISpecialComparisonRegistry { @@ -36,9 +37,10 @@ public interface ISpecialComparisonRegistry * return TheHandler or null. * * @param stack item + * * @return a handler it found for a specific item */ - IItemComparison getSpecialComparison(ItemStack stack); + IItemComparison getSpecialComparison( ItemStack stack ); /** * Register a new special comparison function with AE. @@ -46,5 +48,4 @@ public interface ISpecialComparisonRegistry * @param prov comparison provider */ void addComparisonProvider( IItemComparisonProvider prov ); - } \ No newline at end of file diff --git a/src/api/java/appeng/api/features/IWirelessTermHandler.java b/src/api/java/appeng/api/features/IWirelessTermHandler.java index bec198b8a..cb116e85a 100644 --- a/src/api/java/appeng/api/features/IWirelessTermHandler.java +++ b/src/api/java/appeng/api/features/IWirelessTermHandler.java @@ -23,10 +23,13 @@ package appeng.api.features; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; + import appeng.api.util.IConfigManager; + /** * A handler for a wireless terminal. */ @@ -35,35 +38,37 @@ public interface IWirelessTermHandler extends INetworkEncodable /** * @param is wireless terminal + * * @return true, if usePower, hasPower, etc... can be called for the provided item */ - boolean canHandle(ItemStack is); + 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 wireless terminal * @return true if wireless terminal uses power */ - boolean usePower(EntityPlayer player, double amount, ItemStack is); + boolean usePower( EntityPlayer player, double amount, ItemStack is ); /** * gets the power status of the item. * * @param is wireless terminal + * * @return returns true if there is any power left. */ - boolean hasPower(EntityPlayer player, double amount, ItemStack is); + boolean hasPower( EntityPlayer player, double amount, ItemStack is ); /** * Return the config manager for the wireless terminal. * * @param is wireless terminal + * * @return config manager of wireless terminal */ - IConfigManager getConfigManager(ItemStack is); - + IConfigManager getConfigManager( ItemStack is ); } \ No newline at end of file diff --git a/src/api/java/appeng/api/features/IWirelessTermRegistry.java b/src/api/java/appeng/api/features/IWirelessTermRegistry.java index 49b0e06b2..afab12012 100644 --- a/src/api/java/appeng/api/features/IWirelessTermRegistry.java +++ b/src/api/java/appeng/api/features/IWirelessTermRegistry.java @@ -23,10 +23,12 @@ package appeng.api.features; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + /** * Registration record for a Custom Cell handler. */ @@ -38,25 +40,26 @@ public interface IWirelessTermRegistry * * @param handler wireless handler */ - void registerWirelessHandler(IWirelessTermHandler handler); + void registerWirelessHandler( IWirelessTermHandler handler ); /** * @param is item which might have a handler + * * @return true if there is a handler for this item */ - boolean isWirelessTerminal(ItemStack is); + boolean isWirelessTerminal( ItemStack is ); /** * @param is item with handler + * * @return a register handler for the item in question, or null if there - * isn't one + * isn't one */ - IWirelessTermHandler getWirelessTerminalHandler(ItemStack is); + IWirelessTermHandler getWirelessTerminalHandler( ItemStack is ); /** * opens the wireless terminal gui, the wireless terminal item, must be in * the active slot on the tool bar. */ - void openWirelessTerminalGui(ItemStack item, World w, EntityPlayer player); - + void openWirelessTerminalGui( ItemStack item, World w, EntityPlayer player ); } diff --git a/src/api/java/appeng/api/features/IWorldGen.java b/src/api/java/appeng/api/features/IWorldGen.java index fa02ad1be..4f935dfa6 100644 --- a/src/api/java/appeng/api/features/IWorldGen.java +++ b/src/api/java/appeng/api/features/IWorldGen.java @@ -23,9 +23,11 @@ package appeng.api.features; + import net.minecraft.world.World; import net.minecraft.world.WorldProvider; + public interface IWorldGen { @@ -40,6 +42,5 @@ public interface IWorldGen void disableWorldGenForDimension( WorldGenType type, int dimID ); - boolean isWorldGenEnabled(WorldGenType type, World w); - + boolean isWorldGenEnabled( WorldGenType type, World w ); } diff --git a/src/api/java/appeng/api/implementations/ICraftingPatternItem.java b/src/api/java/appeng/api/implementations/ICraftingPatternItem.java index b13b0c303..6524f6cc5 100644 --- a/src/api/java/appeng/api/implementations/ICraftingPatternItem.java +++ b/src/api/java/appeng/api/implementations/ICraftingPatternItem.java @@ -23,11 +23,14 @@ package appeng.api.implementations; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + import appeng.api.networking.crafting.ICraftingPatternDetails; + /** * Implemented on {@link Item} */ @@ -38,8 +41,9 @@ public interface ICraftingPatternItem * Access Details about a pattern * * @param is pattern - * @param w crafting world + * @param w crafting world + * * @return details of pattern */ - ICraftingPatternDetails getPatternForItem(ItemStack is, World w); + ICraftingPatternDetails getPatternForItem( ItemStack is, World w ); } diff --git a/src/api/java/appeng/api/implementations/IPowerChannelState.java b/src/api/java/appeng/api/implementations/IPowerChannelState.java index dc1c29faf..ee5587929 100644 --- a/src/api/java/appeng/api/implementations/IPowerChannelState.java +++ b/src/api/java/appeng/api/implementations/IPowerChannelState.java @@ -23,6 +23,7 @@ package appeng.api.implementations; + /** * This is intended for use on the client side to provide details to WAILA. */ @@ -38,5 +39,4 @@ public interface IPowerChannelState * @return true if the part/tile isActive */ boolean isActive(); - } diff --git a/src/api/java/appeng/api/implementations/IUpgradeableHost.java b/src/api/java/appeng/api/implementations/IUpgradeableHost.java index cd1f717dd..bbc728e1f 100644 --- a/src/api/java/appeng/api/implementations/IUpgradeableHost.java +++ b/src/api/java/appeng/api/implementations/IUpgradeableHost.java @@ -23,10 +23,13 @@ package appeng.api.implementations; -import appeng.api.util.IConfigurableObject; + import net.minecraft.tileentity.TileEntity; + import appeng.api.config.Upgrades; import appeng.api.implementations.tiles.ISegmentedInventory; +import appeng.api.util.IConfigurableObject; + public interface IUpgradeableHost extends IConfigurableObject, ISegmentedInventory { @@ -34,7 +37,7 @@ public interface IUpgradeableHost extends IConfigurableObject, ISegmentedInvento /** * determine how many of an upgrade are installed. */ - int getInstalledUpgrades(Upgrades u); + int getInstalledUpgrades( Upgrades u ); /** * the tile... @@ -42,5 +45,4 @@ public interface IUpgradeableHost extends IConfigurableObject, ISegmentedInvento * @return tile entity */ TileEntity getTile(); - } diff --git a/src/api/java/appeng/api/implementations/TransitionResult.java b/src/api/java/appeng/api/implementations/TransitionResult.java index 96bd80ea7..e9896874a 100644 --- a/src/api/java/appeng/api/implementations/TransitionResult.java +++ b/src/api/java/appeng/api/implementations/TransitionResult.java @@ -23,6 +23,7 @@ package appeng.api.implementations; + /** * Defines the result of performing a transition from the world into a storage * cell, if its possible, and what the energy usage is. @@ -32,7 +33,8 @@ public class TransitionResult public final boolean success; public final double energyUsage; - public TransitionResult(boolean _success, double power) { + public TransitionResult( boolean _success, double power ) + { this.success = _success; this.energyUsage = power; } diff --git a/src/api/java/appeng/api/implementations/guiobjects/IGuiItem.java b/src/api/java/appeng/api/implementations/guiobjects/IGuiItem.java index 1cf3d18c6..269eea2a2 100644 --- a/src/api/java/appeng/api/implementations/guiobjects/IGuiItem.java +++ b/src/api/java/appeng/api/implementations/guiobjects/IGuiItem.java @@ -23,9 +23,11 @@ package appeng.api.implementations.guiobjects; + import net.minecraft.item.ItemStack; import net.minecraft.world.World; + /** * Implemented on Item objects, to return objects used to manage, and interact * with the contents. @@ -33,6 +35,5 @@ import net.minecraft.world.World; public interface IGuiItem { - IGuiItemObject getGuiObject(ItemStack is, World world, int x, int y, int z); - + IGuiItemObject getGuiObject( ItemStack is, World world, int x, int y, int z ); } diff --git a/src/api/java/appeng/api/implementations/guiobjects/IGuiItemObject.java b/src/api/java/appeng/api/implementations/guiobjects/IGuiItemObject.java index 0d2fa66eb..342187394 100644 --- a/src/api/java/appeng/api/implementations/guiobjects/IGuiItemObject.java +++ b/src/api/java/appeng/api/implementations/guiobjects/IGuiItemObject.java @@ -23,8 +23,10 @@ package appeng.api.implementations.guiobjects; + import net.minecraft.item.ItemStack; + public interface IGuiItemObject { diff --git a/src/api/java/appeng/api/implementations/guiobjects/INetworkTool.java b/src/api/java/appeng/api/implementations/guiobjects/INetworkTool.java index 844f74661..4e0dc9589 100644 --- a/src/api/java/appeng/api/implementations/guiobjects/INetworkTool.java +++ b/src/api/java/appeng/api/implementations/guiobjects/INetworkTool.java @@ -23,9 +23,12 @@ package appeng.api.implementations.guiobjects; + import net.minecraft.inventory.IInventory; + import appeng.api.networking.IGridHost; + /** * Obtained via {@link IGuiItem} getGuiObject */ @@ -33,5 +36,4 @@ public interface INetworkTool extends IInventory, IGuiItemObject { IGridHost getGridHost(); // null for most purposes. - } diff --git a/src/api/java/appeng/api/implementations/guiobjects/IPortableCell.java b/src/api/java/appeng/api/implementations/guiobjects/IPortableCell.java index f307b3883..7a80a00b5 100644 --- a/src/api/java/appeng/api/implementations/guiobjects/IPortableCell.java +++ b/src/api/java/appeng/api/implementations/guiobjects/IPortableCell.java @@ -23,11 +23,13 @@ package appeng.api.implementations.guiobjects; + import appeng.api.networking.energy.IEnergySource; import appeng.api.storage.IMEMonitor; import appeng.api.storage.ITerminalHost; import appeng.api.storage.data.IAEItemStack; + /** * Obtained via {@link IGuiItem} getGuiObject */ diff --git a/src/api/java/appeng/api/implementations/items/IAEItemPowerStorage.java b/src/api/java/appeng/api/implementations/items/IAEItemPowerStorage.java index d78fb7303..0ca4ff49c 100644 --- a/src/api/java/appeng/api/implementations/items/IAEItemPowerStorage.java +++ b/src/api/java/appeng/api/implementations/items/IAEItemPowerStorage.java @@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack; import appeng.api.config.AccessRestriction; import appeng.api.networking.energy.IAEPowerStorage; + /** * Basically the same as {@link IAEPowerStorage}, but for items. */ @@ -48,6 +49,7 @@ public interface IAEItemPowerStorage * return it. * * @param amt to be extracted power from device + * * @return what it could extract */ double extractAEPower( ItemStack is, double amt ); @@ -69,5 +71,4 @@ public interface IAEItemPowerStorage * @return access restriction of network */ AccessRestriction getPowerFlow( ItemStack is ); - } \ No newline at end of file diff --git a/src/api/java/appeng/api/implementations/items/IAEWrench.java b/src/api/java/appeng/api/implementations/items/IAEWrench.java index fc1682653..27ad96d2e 100644 --- a/src/api/java/appeng/api/implementations/items/IAEWrench.java +++ b/src/api/java/appeng/api/implementations/items/IAEWrench.java @@ -23,9 +23,11 @@ package appeng.api.implementations.items; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; + /** * Implemented on AE's wrench(s) as a substitute for if BC's API is not * available. @@ -37,12 +39,11 @@ public interface IAEWrench * Check if the wrench can be used. * * @param player wrenching player - * @param x x pos of wrenched block - * @param y y pos of wrenched block - * @param z z pos of wrenched block + * @param x x pos of wrenched block + * @param y y pos of wrenched block + * @param z z pos of wrenched block * * @return true if wrench can be used */ - boolean canWrench(ItemStack wrench, EntityPlayer player, int x, int y, int z); - + boolean canWrench( ItemStack wrench, EntityPlayer player, int x, int y, int z ); } diff --git a/src/api/java/appeng/api/implementations/items/IBiometricCard.java b/src/api/java/appeng/api/implementations/items/IBiometricCard.java index dcf440fac..49962ef01 100644 --- a/src/api/java/appeng/api/implementations/items/IBiometricCard.java +++ b/src/api/java/appeng/api/implementations/items/IBiometricCard.java @@ -23,13 +23,17 @@ package appeng.api.implementations.items; + +import java.util.EnumSet; + +import net.minecraft.item.ItemStack; + +import com.mojang.authlib.GameProfile; + import appeng.api.config.SecurityPermissions; import appeng.api.features.IPlayerRegistry; import appeng.api.networking.security.ISecurityRegistry; -import com.mojang.authlib.GameProfile; -import net.minecraft.item.ItemStack; -import java.util.EnumSet; public interface IBiometricCard { @@ -37,50 +41,51 @@ public interface IBiometricCard /** * Set the {@link GameProfile} to null, to clear it. */ - void setProfile(ItemStack itemStack, GameProfile username); + void setProfile( ItemStack itemStack, GameProfile username ); /** * @return {@link GameProfile} of the player encoded on this card, or a blank string. */ - GameProfile getProfile(ItemStack is); + GameProfile getProfile( ItemStack is ); /** * @param itemStack card + * * @return the full list of permissions encoded on the card. */ - EnumSet getPermissions(ItemStack itemStack); + EnumSet getPermissions( ItemStack itemStack ); /** * Check if a permission is encoded on the card. * * @param permission card + * * @return true if this permission is set on the card. */ - boolean hasPermission(ItemStack is, SecurityPermissions permission); + boolean hasPermission( ItemStack is, SecurityPermissions permission ); /** * remove a permission from the item stack. - * + * * @param itemStack card * @param permission to be removed permission */ - void removePermission(ItemStack itemStack, SecurityPermissions permission); + void removePermission( ItemStack itemStack, SecurityPermissions permission ); /** * add a permission to the item stack. - * + * * @param itemStack card * @param permission to be added permission */ - void addPermission(ItemStack itemStack, SecurityPermissions permission); + void addPermission( ItemStack itemStack, SecurityPermissions permission ); /** * lets you handle submission of security values on the card for custom behavior. * * @param registry security registry - * @param pr player registry - * @param is card + * @param pr player registry + * @param is card */ - void registerPermissions(ISecurityRegistry registry, IPlayerRegistry pr, ItemStack is); - + void registerPermissions( ISecurityRegistry registry, IPlayerRegistry pr, ItemStack is ); } diff --git a/src/api/java/appeng/api/implementations/items/IGrowableCrystal.java b/src/api/java/appeng/api/implementations/items/IGrowableCrystal.java index c0584fe99..489e2b89c 100644 --- a/src/api/java/appeng/api/implementations/items/IGrowableCrystal.java +++ b/src/api/java/appeng/api/implementations/items/IGrowableCrystal.java @@ -23,15 +23,16 @@ package appeng.api.implementations.items; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.item.ItemStack; + public interface IGrowableCrystal { - ItemStack triggerGrowth(ItemStack is); - - float getMultiplier(Block blk, Material mat); + ItemStack triggerGrowth( ItemStack is ); + float getMultiplier( Block blk, Material mat ); } diff --git a/src/api/java/appeng/api/implementations/items/IItemGroup.java b/src/api/java/appeng/api/implementations/items/IItemGroup.java index 894857302..3d3f8cc0f 100644 --- a/src/api/java/appeng/api/implementations/items/IItemGroup.java +++ b/src/api/java/appeng/api/implementations/items/IItemGroup.java @@ -23,10 +23,12 @@ package appeng.api.implementations.items; -import net.minecraft.item.ItemStack; import java.util.Set; +import net.minecraft.item.ItemStack; + + /** * Lets you specify the name of the group of items this falls under. */ @@ -37,8 +39,8 @@ public interface IItemGroup * returning null, is the same as not implementing the interface at all. * * @param is item + * * @return an unlocalized string to use for the items group name. */ - String getUnlocalizedGroupName(Set otherItems, ItemStack is); - + String getUnlocalizedGroupName( Set otherItems, ItemStack is ); } diff --git a/src/api/java/appeng/api/implementations/items/IMemoryCard.java b/src/api/java/appeng/api/implementations/items/IMemoryCard.java index b332325bb..71a096b45 100644 --- a/src/api/java/appeng/api/implementations/items/IMemoryCard.java +++ b/src/api/java/appeng/api/implementations/items/IMemoryCard.java @@ -23,13 +23,15 @@ package appeng.api.implementations.items; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; + /** * Memory Card API - * + * * AE's Memory Card Item Class implements this interface. */ public interface IMemoryCard @@ -38,7 +40,7 @@ public interface IMemoryCard /** * Configures the data stored on the memory card, the SettingsName, will be * localized when displayed. - * + * * @param is item * @param SettingsName * unlocalized string that represents the tile entity. @@ -47,7 +49,7 @@ public interface IMemoryCard * unlocalized string displayed after the settings name, optional * but can be used to add details to the card for later. */ - void setMemoryCardContents(ItemStack is, String SettingsName, NBTTagCompound data); + void setMemoryCardContents( ItemStack is, String SettingsName, NBTTagCompound data ); /** * returns the settings name provided by a previous call to @@ -55,25 +57,26 @@ public interface IMemoryCard * previous call to setMemoryCardContents. * * @param is item + * * @return setting name */ - String getSettingsName(ItemStack is); + String getSettingsName( ItemStack is ); /** * @param is item + * * @return the NBT Data previously saved by setMemoryCardContents, or an - * empty NBTCompound + * empty NBTCompound */ - NBTTagCompound getData(ItemStack is); + NBTTagCompound getData( ItemStack is ); /** * notify the user of a outcome related to the memory card. - * + * * @param player * that used the card. * @param msg * which message to send. */ - void notifyUser(EntityPlayer player, MemoryCardMessages msg); - + void notifyUser( EntityPlayer player, MemoryCardMessages msg ); } diff --git a/src/api/java/appeng/api/implementations/items/ISpatialStorageCell.java b/src/api/java/appeng/api/implementations/items/ISpatialStorageCell.java index 8f563291d..8bc6d29bc 100644 --- a/src/api/java/appeng/api/implementations/items/ISpatialStorageCell.java +++ b/src/api/java/appeng/api/implementations/items/ISpatialStorageCell.java @@ -23,12 +23,15 @@ package appeng.api.implementations.items; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + import appeng.api.implementations.TransitionResult; import appeng.api.util.WorldCoord; + /** * Implemented on a {@link Item} */ @@ -37,56 +40,62 @@ public interface ISpatialStorageCell /** * @param is spatial storage cell + * * @return true if this item is a spatial storage cell */ - boolean isSpatialStorage(ItemStack is); + boolean isSpatialStorage( ItemStack is ); /** * @param is spatial storage cell + * * @return the maximum size of the spatial storage cell along any given axis */ - int getMaxStoredDim(ItemStack is); + int getMaxStoredDim( ItemStack is ); /** * @param is spatial storage cell + * * @return the world for this cell */ - World getWorld(ItemStack is); + World getWorld( ItemStack is ); /** * get the currently stored size. * * @param is spatial storage cell + * * @return size of spatial */ - WorldCoord getStoredSize(ItemStack is); + WorldCoord getStoredSize( ItemStack is ); /** * Minimum coordinates in its world for the storage cell. * * @param is spatial storage cell + * * @return minimum coordinate of dimension */ - WorldCoord getMin(ItemStack is); + WorldCoord getMin( ItemStack is ); /** * Maximum coordinates in its world for the storage cell. * * @param is spatial storage cell + * * @return maximum coordinate of dimension */ - WorldCoord getMax(ItemStack is); + WorldCoord getMax( ItemStack is ); /** * Perform a spatial swap with the contents of the cell, and the world. - * + * * @param is spatial storage cell * @param w world of spatial * @param min min coord * @param max max coord * @param doTransition transition + * * @return result of transition */ - TransitionResult doSpatialTransition(ItemStack is, World w, WorldCoord min, WorldCoord max, boolean doTransition); - + TransitionResult doSpatialTransition( ItemStack is, World w, WorldCoord min, WorldCoord max, boolean doTransition ); } \ No newline at end of file diff --git a/src/api/java/appeng/api/implementations/items/IStorageCell.java b/src/api/java/appeng/api/implementations/items/IStorageCell.java index 10339b6e9..ba2b3fc10 100644 --- a/src/api/java/appeng/api/implementations/items/IStorageCell.java +++ b/src/api/java/appeng/api/implementations/items/IStorageCell.java @@ -23,20 +23,22 @@ package appeng.api.implementations.items; + import net.minecraft.item.ItemStack; + import appeng.api.storage.ICellWorkbenchItem; import appeng.api.storage.data.IAEItemStack; + /** * 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! - * + * * Good cause it means you don't have to do anything, bad because you have * little to no control over it. - * + * * The standard AE implementation only provides 1-63 Types - * */ public interface IStorageCell extends ICellWorkbenchItem { @@ -46,37 +48,41 @@ public interface IStorageCell extends ICellWorkbenchItem * The limit is ({@link Integer#MAX_VALUE} + 1) / 8. * * @param cellItem item + * * @return number of bytes */ - int getBytes(ItemStack cellItem); + int getBytes( ItemStack cellItem ); /** * Determines the number of bytes used for any type included on the cell. * * @param cellItem item + * * @return number of bytes */ - int BytePerType(ItemStack cellItem); + int BytePerType( ItemStack cellItem ); /** * Must be between 1 and 63, indicates how many types you want to store on * the item. * * @param cellItem item + * * @return number of types */ - int getTotalTypes(ItemStack cellItem); + int getTotalTypes( ItemStack cellItem ); /** * 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 item * @param requestedAddition requested addition + * * @return true to preventAdditionOfItem */ - boolean isBlackListed(ItemStack cellItem, IAEItemStack requestedAddition); + boolean isBlackListed( ItemStack cellItem, IAEItemStack requestedAddition ); /** * Allows you to specify if this storage cell can be stored inside other @@ -84,8 +90,8 @@ public interface IStorageCell extends ICellWorkbenchItem * that are not general purpose storage. * * @return true if the storage cell can be stored inside other storage - * cells, this is generally false, except for certain situations - * such as the matter cannon. + * cells, this is generally false, except for certain situations + * such as the matter cannon. */ boolean storableInStorageCell(); @@ -94,9 +100,10 @@ public interface IStorageCell extends ICellWorkbenchItem * cell. * * @param i item + * * @return if the ItemStack should behavior as a storage cell. */ - boolean isStorageCell(ItemStack i); + boolean isStorageCell( ItemStack i ); /** * @return drain in ae/t this storage cell will use. diff --git a/src/api/java/appeng/api/implementations/items/IStorageComponent.java b/src/api/java/appeng/api/implementations/items/IStorageComponent.java index 61d744493..b1958f9fc 100644 --- a/src/api/java/appeng/api/implementations/items/IStorageComponent.java +++ b/src/api/java/appeng/api/implementations/items/IStorageComponent.java @@ -23,9 +23,11 @@ package appeng.api.implementations.items; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; + /** * Implemented on a {@link Item} */ @@ -38,16 +40,17 @@ public interface IStorageComponent * the condenser. * * @param is item + * * @return number of bytes */ - int getBytes(ItemStack is); + int getBytes( ItemStack is ); /** * Just true or false for the item stack. * * @param is item + * * @return true if item is a storage component */ - boolean isStorageComponent(ItemStack is); - + boolean isStorageComponent( ItemStack is ); } diff --git a/src/api/java/appeng/api/implementations/items/IUpgradeModule.java b/src/api/java/appeng/api/implementations/items/IUpgradeModule.java index 2f5532654..0b06911e0 100644 --- a/src/api/java/appeng/api/implementations/items/IUpgradeModule.java +++ b/src/api/java/appeng/api/implementations/items/IUpgradeModule.java @@ -23,16 +23,19 @@ package appeng.api.implementations.items; + import net.minecraft.item.ItemStack; + import appeng.api.config.Upgrades; + public interface IUpgradeModule { /** * @param itemstack item with potential upgrades + * * @return null, or a valid upgrade type. */ - Upgrades getType(ItemStack itemstack); - + Upgrades getType( ItemStack itemstack ); } diff --git a/src/api/java/appeng/api/implementations/items/MemoryCardMessages.java b/src/api/java/appeng/api/implementations/items/MemoryCardMessages.java index 631f5b32f..016213148 100644 --- a/src/api/java/appeng/api/implementations/items/MemoryCardMessages.java +++ b/src/api/java/appeng/api/implementations/items/MemoryCardMessages.java @@ -23,6 +23,7 @@ package appeng.api.implementations.items; + /** * Status Results for use with {@link IMemoryCard} */ diff --git a/src/api/java/appeng/api/implementations/parts/IPartCable.java b/src/api/java/appeng/api/implementations/parts/IPartCable.java index 794079b86..ac8d4df8b 100644 --- a/src/api/java/appeng/api/implementations/parts/IPartCable.java +++ b/src/api/java/appeng/api/implementations/parts/IPartCable.java @@ -23,16 +23,19 @@ package appeng.api.implementations.parts; + +import java.util.EnumSet; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; + import appeng.api.networking.IGridHost; import appeng.api.parts.BusSupport; import appeng.api.parts.IPart; import appeng.api.parts.IPartHost; import appeng.api.util.AECableType; import appeng.api.util.AEColor; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.common.util.ForgeDirection; -import java.util.EnumSet; /** * Implemented on the {@link IPart}s cable objects that can be placed at {@link ForgeDirection}.UNKNOWN in @@ -60,25 +63,26 @@ public interface IPartCable extends IPart, IGridHost * Change the color of the cable, this should cost a small amount of dye, or something. * * @param newColor new color + * * @return if the color change was successful. */ - boolean changeColor(AEColor newColor, EntityPlayer who); + boolean changeColor( AEColor newColor, EntityPlayer who ); /** * Change sides on the cables node. - * + * * Called by AE, do not invoke. * * @param sides sides of cable */ - void setValidSides(EnumSet sides); + void setValidSides( EnumSet sides ); /** * used to tests if a cable connects to neighbors visually. * * @param side neighbor side + * * @return true if this side is currently connects to an external block. */ - boolean isConnected(ForgeDirection side); - + boolean isConnected( ForgeDirection side ); } diff --git a/src/api/java/appeng/api/implementations/parts/IPartMonitor.java b/src/api/java/appeng/api/implementations/parts/IPartMonitor.java index 6526ce831..8b788e844 100644 --- a/src/api/java/appeng/api/implementations/parts/IPartMonitor.java +++ b/src/api/java/appeng/api/implementations/parts/IPartMonitor.java @@ -23,9 +23,11 @@ package appeng.api.implementations.parts; + import appeng.api.networking.IGridHost; import appeng.api.parts.IPart; + /** * Implemented by all screen like parts provided by AE. */ @@ -34,8 +36,7 @@ public interface IPartMonitor extends IPart, IGridHost /** * @return if the device is online you should check this before providing - * any other information. + * any other information. */ boolean isPowered(); - } diff --git a/src/api/java/appeng/api/implementations/parts/IPartStorageMonitor.java b/src/api/java/appeng/api/implementations/parts/IPartStorageMonitor.java index 262158483..9bdfe650c 100644 --- a/src/api/java/appeng/api/implementations/parts/IPartStorageMonitor.java +++ b/src/api/java/appeng/api/implementations/parts/IPartStorageMonitor.java @@ -23,11 +23,13 @@ package appeng.api.implementations.parts; + import appeng.api.networking.IGridHost; import appeng.api.parts.IPart; import appeng.api.storage.data.IAEStack; import appeng.api.util.INetworkToolAgent; + /** * The Storage monitor is a {@link IPart} located on the sides of a IPartHost */ @@ -36,8 +38,8 @@ public interface IPartStorageMonitor extends IPartMonitor, IPart, IGridHost, INe /** * @return the item being displayed on the storage monitor, in AEStack Form, can be either a IAEItemStack or an - * IAEFluidStack the quantity is important remember to use getStackSize() on the IAEStack, and not on the - * FluidStack/ItemStack acquired from it. + * IAEFluidStack the quantity is important remember to use getStackSize() on the IAEStack, and not on the + * FluidStack/ItemStack acquired from it. */ IAEStack getDisplayed(); @@ -45,5 +47,4 @@ public interface IPartStorageMonitor extends IPartMonitor, IPart, IGridHost, INe * @return the current locked state of the Storage Monitor */ boolean isLocked(); - } \ No newline at end of file diff --git a/src/api/java/appeng/api/implementations/tiles/IColorableTile.java b/src/api/java/appeng/api/implementations/tiles/IColorableTile.java index 8e9ea1b5d..365a3474d 100644 --- a/src/api/java/appeng/api/implementations/tiles/IColorableTile.java +++ b/src/api/java/appeng/api/implementations/tiles/IColorableTile.java @@ -23,15 +23,17 @@ package appeng.api.implementations.tiles; + import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.util.ForgeDirection; + import appeng.api.util.AEColor; + public interface IColorableTile { AEColor getColor(); - boolean recolourBlock(ForgeDirection side, AEColor colour, EntityPlayer who); - + boolean recolourBlock( ForgeDirection side, AEColor colour, EntityPlayer who ); } diff --git a/src/api/java/appeng/api/implementations/tiles/ICraftingMachine.java b/src/api/java/appeng/api/implementations/tiles/ICraftingMachine.java index 6605dd72d..360990794 100644 --- a/src/api/java/appeng/api/implementations/tiles/ICraftingMachine.java +++ b/src/api/java/appeng/api/implementations/tiles/ICraftingMachine.java @@ -23,8 +23,10 @@ package appeng.api.implementations.tiles; + import net.minecraft.inventory.InventoryCrafting; import net.minecraftforge.common.util.ForgeDirection; + import appeng.api.networking.crafting.ICraftingPatternDetails; public interface ICraftingMachine diff --git a/src/api/java/appeng/api/implementations/tiles/ICrystalGrowthAccelerator.java b/src/api/java/appeng/api/implementations/tiles/ICrystalGrowthAccelerator.java index 49754a534..9d8a9c29d 100644 --- a/src/api/java/appeng/api/implementations/tiles/ICrystalGrowthAccelerator.java +++ b/src/api/java/appeng/api/implementations/tiles/ICrystalGrowthAccelerator.java @@ -23,9 +23,9 @@ package appeng.api.implementations.tiles; + public interface ICrystalGrowthAccelerator { boolean isPowered(); - } diff --git a/src/api/java/appeng/api/implementations/tiles/IMEChest.java b/src/api/java/appeng/api/implementations/tiles/IMEChest.java index f93f16c5b..bbe957a99 100644 --- a/src/api/java/appeng/api/implementations/tiles/IMEChest.java +++ b/src/api/java/appeng/api/implementations/tiles/IMEChest.java @@ -23,8 +23,10 @@ package appeng.api.implementations.tiles; + import appeng.api.networking.energy.IEnergySource; + public interface IMEChest extends IChestOrDrive, ITileStorageMonitorable, IEnergySource { diff --git a/src/api/java/appeng/api/implementations/tiles/ISegmentedInventory.java b/src/api/java/appeng/api/implementations/tiles/ISegmentedInventory.java index 85cac5927..c73a8a53f 100644 --- a/src/api/java/appeng/api/implementations/tiles/ISegmentedInventory.java +++ b/src/api/java/appeng/api/implementations/tiles/ISegmentedInventory.java @@ -23,8 +23,10 @@ package appeng.api.implementations.tiles; + import net.minecraft.inventory.IInventory; + public interface ISegmentedInventory { @@ -33,8 +35,8 @@ public interface ISegmentedInventory * them a real inventories will result in duplication. * * @param name inventory name + * * @return inventory with inventory name */ - IInventory getInventoryByName(String name); - + IInventory getInventoryByName( String name ); } diff --git a/src/api/java/appeng/api/implementations/tiles/ITileStorageMonitorable.java b/src/api/java/appeng/api/implementations/tiles/ITileStorageMonitorable.java index 58433e354..09419f10b 100644 --- a/src/api/java/appeng/api/implementations/tiles/ITileStorageMonitorable.java +++ b/src/api/java/appeng/api/implementations/tiles/ITileStorageMonitorable.java @@ -23,16 +23,18 @@ package appeng.api.implementations.tiles; + import net.minecraftforge.common.util.ForgeDirection; + import appeng.api.networking.security.BaseActionSource; import appeng.api.storage.IStorageMonitorable; + /** * Implemented on inventories that can share their inventories with other networks, best example, ME Interface. */ public interface ITileStorageMonitorable { - IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src); - + IStorageMonitorable getMonitorable( ForgeDirection side, BaseActionSource src ); } diff --git a/src/api/java/appeng/api/implementations/tiles/IViewCellStorage.java b/src/api/java/appeng/api/implementations/tiles/IViewCellStorage.java index 187620712..4a81ae12b 100644 --- a/src/api/java/appeng/api/implementations/tiles/IViewCellStorage.java +++ b/src/api/java/appeng/api/implementations/tiles/IViewCellStorage.java @@ -23,8 +23,10 @@ package appeng.api.implementations.tiles; + import net.minecraft.inventory.IInventory; + public interface IViewCellStorage { @@ -34,5 +36,4 @@ public interface IViewCellStorage * @return inventory with at least 5 slot */ IInventory getViewCellStorage(); - } diff --git a/src/api/java/appeng/api/implementations/tiles/IWirelessAccessPoint.java b/src/api/java/appeng/api/implementations/tiles/IWirelessAccessPoint.java index 0decc332f..038bc52db 100644 --- a/src/api/java/appeng/api/implementations/tiles/IWirelessAccessPoint.java +++ b/src/api/java/appeng/api/implementations/tiles/IWirelessAccessPoint.java @@ -23,10 +23,12 @@ package appeng.api.implementations.tiles; + import appeng.api.networking.IGrid; import appeng.api.networking.security.IActionHost; import appeng.api.util.DimensionalCoord; + public interface IWirelessAccessPoint extends IActionHost { @@ -49,5 +51,4 @@ public interface IWirelessAccessPoint extends IActionHost * @return grid of linked WAP */ IGrid getGrid(); - } diff --git a/src/api/java/appeng/api/movable/IMovableTile.java b/src/api/java/appeng/api/movable/IMovableTile.java index d9dfe6985..feaaff287 100644 --- a/src/api/java/appeng/api/movable/IMovableTile.java +++ b/src/api/java/appeng/api/movable/IMovableTile.java @@ -23,6 +23,7 @@ package appeng.api.movable; + /** * You can implement this, or use the IMovableRegistry to white list your tile, * please see the registry for more information. @@ -42,5 +43,4 @@ public interface IMovableTile * notification that your block was moved, called after validate. */ void doneMoving(); - } diff --git a/src/api/java/appeng/api/networking/GridFlags.java b/src/api/java/appeng/api/networking/GridFlags.java index a66bd4e95..b698fb93a 100644 --- a/src/api/java/appeng/api/networking/GridFlags.java +++ b/src/api/java/appeng/api/networking/GridFlags.java @@ -23,6 +23,7 @@ package appeng.api.networking; + /** * Various flags to determine network node behavior. */ diff --git a/src/api/java/appeng/api/networking/GridNotification.java b/src/api/java/appeng/api/networking/GridNotification.java index c3b96f974..b53188d77 100644 --- a/src/api/java/appeng/api/networking/GridNotification.java +++ b/src/api/java/appeng/api/networking/GridNotification.java @@ -23,6 +23,7 @@ package appeng.api.networking; + public enum GridNotification { /** diff --git a/src/api/java/appeng/api/networking/IGridCacheRegistry.java b/src/api/java/appeng/api/networking/IGridCacheRegistry.java index 4f2eb326d..b54df8dae 100644 --- a/src/api/java/appeng/api/networking/IGridCacheRegistry.java +++ b/src/api/java/appeng/api/networking/IGridCacheRegistry.java @@ -23,8 +23,10 @@ package appeng.api.networking; + import java.util.HashMap; + /** * A registry of grid caches to extend grid functionality. */ @@ -36,7 +38,7 @@ public interface IGridCacheRegistry * * @param iface grid cache class */ - void registerGridCache(Class iface, Class implementation); + void registerGridCache( Class iface, Class implementation ); /** * requests a new INSTANCE of a grid cache for use, used internally @@ -45,6 +47,5 @@ public interface IGridCacheRegistry * * @return a new HashMap of IGridCaches from the registry, called from IGrid when constructing a new grid. */ - HashMap, IGridCache> createCacheInstance(IGrid grid); - + HashMap, IGridCache> createCacheInstance( IGrid grid ); } diff --git a/src/api/java/appeng/api/networking/IGridMultiblock.java b/src/api/java/appeng/api/networking/IGridMultiblock.java index ec4fed3a2..7c3844bb7 100644 --- a/src/api/java/appeng/api/networking/IGridMultiblock.java +++ b/src/api/java/appeng/api/networking/IGridMultiblock.java @@ -23,8 +23,10 @@ package appeng.api.networking; + import java.util.Iterator; + /** * An extension of IGridBlock, only means something when your getFlags() contains REQUIRE_CHANNEL, when done properly it * will call the method to get a list of all related nodes and give each of them a channel simultaneously for the entire @@ -39,5 +41,4 @@ public interface IGridMultiblock extends IGridBlock * @return an iterator that will iterate all the nodes for the multiblock. ( read-only iterator expected. ) */ Iterator getMultiblockNodes(); - } diff --git a/src/api/java/appeng/api/networking/IGridNode.java b/src/api/java/appeng/api/networking/IGridNode.java index 37c19e4e6..e477babe7 100644 --- a/src/api/java/appeng/api/networking/IGridNode.java +++ b/src/api/java/appeng/api/networking/IGridNode.java @@ -23,13 +23,15 @@ package appeng.api.networking; -import appeng.api.IAppEngApi; -import appeng.api.util.IReadOnlyCollection; + +import java.util.EnumSet; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.EnumSet; +import appeng.api.IAppEngApi; +import appeng.api.util.IReadOnlyCollection; /** * diff --git a/src/api/java/appeng/api/networking/IGridStorage.java b/src/api/java/appeng/api/networking/IGridStorage.java index 100d3b1a8..0f9e9b7b5 100644 --- a/src/api/java/appeng/api/networking/IGridStorage.java +++ b/src/api/java/appeng/api/networking/IGridStorage.java @@ -23,8 +23,10 @@ package appeng.api.networking; + import net.minecraft.nbt.NBTTagCompound; + public interface IGridStorage { @@ -37,5 +39,4 @@ public interface IGridStorage * @return the id for this grid storage object, used internally */ long getID(); - } diff --git a/src/api/java/appeng/api/networking/IMachineSet.java b/src/api/java/appeng/api/networking/IMachineSet.java index e0f5b7d8a..7d57b52cf 100644 --- a/src/api/java/appeng/api/networking/IMachineSet.java +++ b/src/api/java/appeng/api/networking/IMachineSet.java @@ -23,8 +23,10 @@ package appeng.api.networking; + import appeng.api.util.IReadOnlyCollection; + public interface IMachineSet extends IReadOnlyCollection { @@ -32,5 +34,4 @@ public interface IMachineSet extends IReadOnlyCollection * @return the machine class for this set. */ Class getMachineClass(); - } diff --git a/src/api/java/appeng/api/networking/crafting/CraftingItemList.java b/src/api/java/appeng/api/networking/crafting/CraftingItemList.java index 56a00b66b..c84c275d7 100644 --- a/src/api/java/appeng/api/networking/crafting/CraftingItemList.java +++ b/src/api/java/appeng/api/networking/crafting/CraftingItemList.java @@ -23,6 +23,7 @@ package appeng.api.networking.crafting; + public enum CraftingItemList { ALL, STORAGE, ACTIVE, PENDING diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingCPU.java b/src/api/java/appeng/api/networking/crafting/ICraftingCPU.java index ecb9da2e6..5dbc40e87 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingCPU.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingCPU.java @@ -23,10 +23,12 @@ package appeng.api.networking.crafting; + import appeng.api.networking.security.BaseActionSource; import appeng.api.networking.storage.IBaseMonitor; import appeng.api.storage.data.IAEItemStack; + public interface ICraftingCPU extends IBaseMonitor { @@ -54,5 +56,4 @@ public interface ICraftingCPU extends IBaseMonitor * @return an empty string or the name of the cpu. */ String getName(); - } diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingGrid.java b/src/api/java/appeng/api/networking/crafting/ICraftingGrid.java index 9b544f989..d5a943206 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingGrid.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingGrid.java @@ -23,15 +23,18 @@ package appeng.api.networking.crafting; + +import java.util.concurrent.Future; + +import net.minecraft.world.World; + +import com.google.common.collect.ImmutableCollection; +import com.google.common.collect.ImmutableSet; + import appeng.api.networking.IGrid; import appeng.api.networking.IGridCache; import appeng.api.networking.security.BaseActionSource; import appeng.api.storage.data.IAEItemStack; -import com.google.common.collect.ImmutableCollection; -import com.google.common.collect.ImmutableSet; -import net.minecraft.world.World; - -import java.util.concurrent.Future; public interface ICraftingGrid extends IGridCache { diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingJob.java b/src/api/java/appeng/api/networking/crafting/ICraftingJob.java index e0cc5cc76..559012303 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingJob.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingJob.java @@ -23,15 +23,17 @@ package appeng.api.networking.crafting; + import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; + public interface ICraftingJob { /** * @return if this job is a simulation, simulations cannot be submitted and only represent 1 possible future - * crafting job with fake items. + * crafting job with fake items. */ boolean isSimulation(); @@ -46,11 +48,10 @@ public interface ICraftingJob * * @param plan plan */ - void populatePlan(IItemList plan); + void populatePlan( IItemList plan ); /** * @return the final output of the job. */ IAEItemStack getOutput(); - } diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingLink.java b/src/api/java/appeng/api/networking/crafting/ICraftingLink.java index 5795d83a0..b39767244 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingLink.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingLink.java @@ -23,8 +23,10 @@ package appeng.api.networking.crafting; + import net.minecraft.nbt.NBTTagCompound; + public interface ICraftingLink { @@ -53,11 +55,10 @@ public interface ICraftingLink * * @param tag to be written data */ - void writeToNBT(NBTTagCompound tag); + void writeToNBT( NBTTagCompound tag ); /** * @return the crafting ID for this link. */ String getCraftingID(); - } diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingMedium.java b/src/api/java/appeng/api/networking/crafting/ICraftingMedium.java index d0bf2c0af..3cb7da319 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingMedium.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingMedium.java @@ -23,8 +23,10 @@ package appeng.api.networking.crafting; + import net.minecraft.inventory.InventoryCrafting; + /** * A place to send Items for crafting purposes, this is considered part of AE's External crafting system. */ @@ -36,14 +38,14 @@ public interface ICraftingMedium * possible the output should be directed. * * @param patternDetails details - * @param table crafting table + * @param table crafting table + * * @return if the pattern was successfully pushed. */ - boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table); + boolean pushPattern( ICraftingPatternDetails patternDetails, InventoryCrafting table ); /** * @return if this is false, the crafting engine will refuse to send new jobs to this medium. */ boolean isBusy(); - } diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingPatternDetails.java b/src/api/java/appeng/api/networking/crafting/ICraftingPatternDetails.java index 94ae6dd4c..e66625869 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingPatternDetails.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingPatternDetails.java @@ -23,9 +23,11 @@ package appeng.api.networking.crafting; + import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + import appeng.api.implementations.ICraftingPatternItem; import appeng.api.storage.data.IAEItemStack; diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingProvider.java b/src/api/java/appeng/api/networking/crafting/ICraftingProvider.java index a7b407a14..79f89d448 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingProvider.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingProvider.java @@ -23,8 +23,10 @@ package appeng.api.networking.crafting; + import appeng.api.networking.events.MENetworkCraftingPatternChange; + /** * Allows a IGridHost to provide crafting patterns to the network, post a {@link MENetworkCraftingPatternChange} to tell * AE2 to update. @@ -37,6 +39,5 @@ public interface ICraftingProvider extends ICraftingMedium * * @param craftingTracker crafting helper */ - void provideCrafting(ICraftingProviderHelper craftingTracker); - + void provideCrafting( ICraftingProviderHelper craftingTracker ); } diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingProviderHelper.java b/src/api/java/appeng/api/networking/crafting/ICraftingProviderHelper.java index 4213b6836..ba666de9b 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingProviderHelper.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingProviderHelper.java @@ -23,8 +23,10 @@ package appeng.api.networking.crafting; + import appeng.api.storage.data.IAEItemStack; + /** * Passed to a ICraftingProvider as a interface to manipulate the available crafting jobs. */ @@ -34,11 +36,10 @@ public interface ICraftingProviderHelper /** * Add new Pattern to AE's crafting cache. */ - void addCraftingOption(ICraftingMedium medium, ICraftingPatternDetails api); + void addCraftingOption( ICraftingMedium medium, ICraftingPatternDetails api ); /** * Set an item can Emitable */ - void setEmitable(IAEItemStack what); - + void setEmitable( IAEItemStack what ); } diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingRequester.java b/src/api/java/appeng/api/networking/crafting/ICraftingRequester.java index 6bc5de53d..3665ca14e 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingRequester.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingRequester.java @@ -23,12 +23,13 @@ package appeng.api.networking.crafting; + +import com.google.common.collect.ImmutableSet; + import appeng.api.config.Actionable; import appeng.api.networking.security.IActionHost; import appeng.api.storage.data.IAEItemStack; -import com.google.common.collect.ImmutableSet; - public interface ICraftingRequester extends IActionHost { diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingWatcher.java b/src/api/java/appeng/api/networking/crafting/ICraftingWatcher.java index c21dcdf09..727f2f56a 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingWatcher.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingWatcher.java @@ -23,10 +23,12 @@ package appeng.api.networking.crafting; + import java.util.Collection; import appeng.api.storage.data.IAEStack; + public interface ICraftingWatcher extends Collection { diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingWatcherHost.java b/src/api/java/appeng/api/networking/crafting/ICraftingWatcherHost.java index b120ed834..ed6f6f9cc 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingWatcherHost.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingWatcherHost.java @@ -23,8 +23,10 @@ package appeng.api.networking.crafting; + import appeng.api.storage.data.IAEItemStack; + public interface ICraftingWatcherHost { @@ -34,14 +36,13 @@ public interface ICraftingWatcherHost * * @param newWatcher crafting watcher for this host */ - void updateWatcher(ICraftingWatcher newWatcher); + void updateWatcher( ICraftingWatcher newWatcher ); /** * Called when a crafting status changes. * * @param craftingGrid current crafting grid - * @param what change + * @param what change */ - void onRequestChange(ICraftingGrid craftingGrid, IAEItemStack what); - + void onRequestChange( ICraftingGrid craftingGrid, IAEItemStack what ); } diff --git a/src/api/java/appeng/api/networking/energy/IEnergyGridProvider.java b/src/api/java/appeng/api/networking/energy/IEnergyGridProvider.java index d9176a2fd..b24af8e32 100644 --- a/src/api/java/appeng/api/networking/energy/IEnergyGridProvider.java +++ b/src/api/java/appeng/api/networking/energy/IEnergyGridProvider.java @@ -23,16 +23,17 @@ package appeng.api.networking.energy; + import java.util.Set; import appeng.api.config.Actionable; + /** * internal use only. */ public interface IEnergyGridProvider { - /** * internal use only */ @@ -47,5 +48,4 @@ public interface IEnergyGridProvider * internal use only */ double getEnergyDemand( double d, Set seen ); - } diff --git a/src/api/java/appeng/api/networking/energy/IEnergyWatcher.java b/src/api/java/appeng/api/networking/energy/IEnergyWatcher.java index 1bfd48fd5..5543df6da 100644 --- a/src/api/java/appeng/api/networking/energy/IEnergyWatcher.java +++ b/src/api/java/appeng/api/networking/energy/IEnergyWatcher.java @@ -23,8 +23,10 @@ package appeng.api.networking.energy; + import java.util.Collection; + public interface IEnergyWatcher extends Collection { diff --git a/src/api/java/appeng/api/networking/energy/IEnergyWatcherHost.java b/src/api/java/appeng/api/networking/energy/IEnergyWatcherHost.java index 66ef4e72a..5f5237f0d 100644 --- a/src/api/java/appeng/api/networking/energy/IEnergyWatcherHost.java +++ b/src/api/java/appeng/api/networking/energy/IEnergyWatcherHost.java @@ -23,6 +23,7 @@ package appeng.api.networking.energy; + public interface IEnergyWatcherHost { @@ -32,13 +33,12 @@ public interface IEnergyWatcherHost * * @param newWatcher new watcher */ - void updateWatcher(IEnergyWatcher newWatcher); + void updateWatcher( IEnergyWatcher newWatcher ); /** * Called when a threshold is crossed. * * @param energyGrid grid */ - void onThresholdPass(IEnergyGrid energyGrid); - + void onThresholdPass( IEnergyGrid energyGrid ); } diff --git a/src/api/java/appeng/api/networking/events/MENetworkChannelChanged.java b/src/api/java/appeng/api/networking/events/MENetworkChannelChanged.java index 8efe223d5..1ddee58df 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkChannelChanged.java +++ b/src/api/java/appeng/api/networking/events/MENetworkChannelChanged.java @@ -23,8 +23,10 @@ package appeng.api.networking.events; + import appeng.api.networking.IGridNode; + /** * Posted by storage devices to inform AE the channel cache that the included node has changed its mind about its * channel requirements. @@ -34,8 +36,8 @@ public class MENetworkChannelChanged extends MENetworkEvent public final IGridNode node; - public MENetworkChannelChanged(IGridNode n) { + public MENetworkChannelChanged( IGridNode n ) + { this.node = n; } - } diff --git a/src/api/java/appeng/api/networking/events/MENetworkControllerChange.java b/src/api/java/appeng/api/networking/events/MENetworkControllerChange.java index 9316134a6..040a3d4aa 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkControllerChange.java +++ b/src/api/java/appeng/api/networking/events/MENetworkControllerChange.java @@ -23,6 +23,7 @@ package appeng.api.networking.events; + /** * Event posted when the networks controller state changes, this can be from no * controller to 1 controller, or any time the network changes from conflicted diff --git a/src/api/java/appeng/api/networking/events/MENetworkCraftingCpuChange.java b/src/api/java/appeng/api/networking/events/MENetworkCraftingCpuChange.java index 76848f70b..34a95c642 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkCraftingCpuChange.java +++ b/src/api/java/appeng/api/networking/events/MENetworkCraftingCpuChange.java @@ -23,15 +23,17 @@ package appeng.api.networking.events; + import appeng.api.networking.IGridNode; + public class MENetworkCraftingCpuChange extends MENetworkEvent { public final IGridNode node; - public MENetworkCraftingCpuChange(IGridNode n) { + public MENetworkCraftingCpuChange( IGridNode n ) + { this.node = n; } - } diff --git a/src/api/java/appeng/api/networking/events/MENetworkCraftingPatternChange.java b/src/api/java/appeng/api/networking/events/MENetworkCraftingPatternChange.java index 5afa58a0e..8e0642652 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkCraftingPatternChange.java +++ b/src/api/java/appeng/api/networking/events/MENetworkCraftingPatternChange.java @@ -23,18 +23,20 @@ package appeng.api.networking.events; + import appeng.api.networking.IGridNode; import appeng.api.networking.crafting.ICraftingProvider; + public class MENetworkCraftingPatternChange extends MENetworkEvent { public final ICraftingProvider provider; public final IGridNode node; - public MENetworkCraftingPatternChange(ICraftingProvider p, IGridNode n) { + public MENetworkCraftingPatternChange( ICraftingProvider p, IGridNode n ) + { this.provider = p; this.node = n; } - } diff --git a/src/api/java/appeng/api/networking/events/MENetworkEventSubscribe.java b/src/api/java/appeng/api/networking/events/MENetworkEventSubscribe.java index 936174947..198f5306f 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkEventSubscribe.java +++ b/src/api/java/appeng/api/networking/events/MENetworkEventSubscribe.java @@ -23,16 +23,19 @@ package appeng.api.networking.events; + import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import appeng.api.networking.IGridCache; import appeng.api.networking.IGridHost; + /** * Usable on any {@link IGridHost}, or {@link IGridCache} */ -@Retention(RetentionPolicy.RUNTIME) -public @interface MENetworkEventSubscribe { +@Retention( RetentionPolicy.RUNTIME ) +public @interface MENetworkEventSubscribe +{ } diff --git a/src/api/java/appeng/api/networking/events/MENetworkPostCacheConstruction.java b/src/api/java/appeng/api/networking/events/MENetworkPostCacheConstruction.java index 791259851..1fddaa8ae 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkPostCacheConstruction.java +++ b/src/api/java/appeng/api/networking/events/MENetworkPostCacheConstruction.java @@ -23,6 +23,7 @@ package appeng.api.networking.events; + /** * Posted after all the caches are available, but before the grid is fully * constructed, can be used to perform cross cache construction processes. diff --git a/src/api/java/appeng/api/networking/events/MENetworkSecurityChange.java b/src/api/java/appeng/api/networking/events/MENetworkSecurityChange.java index d3e3f928d..968d84752 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkSecurityChange.java +++ b/src/api/java/appeng/api/networking/events/MENetworkSecurityChange.java @@ -23,6 +23,7 @@ package appeng.api.networking.events; + /** * Posted by the security framework when permissions change */ diff --git a/src/api/java/appeng/api/networking/events/MENetworkSpatialEvent.java b/src/api/java/appeng/api/networking/events/MENetworkSpatialEvent.java index 7d93abf3b..d02a6c2d7 100644 --- a/src/api/java/appeng/api/networking/events/MENetworkSpatialEvent.java +++ b/src/api/java/appeng/api/networking/events/MENetworkSpatialEvent.java @@ -20,11 +20,12 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - package appeng.api.networking.events; + import appeng.api.networking.IGridHost; + /** * An event that is posted whenever a spatial IO is active, called for IGridCache */ @@ -37,7 +38,7 @@ public class MENetworkSpatialEvent extends MENetworkEvent * @param SpatialIO ( INSTANCE of the SpatialIO block ) * @param EnergyUsage ( the amount of energy that the SpatialIO uses) */ - public MENetworkSpatialEvent(IGridHost SpatialIO, double EnergyUsage) + public MENetworkSpatialEvent( IGridHost SpatialIO, double EnergyUsage ) { this.host = SpatialIO; this.spatialEnergyUsage = EnergyUsage; diff --git a/src/api/java/appeng/api/networking/pathing/ControllerState.java b/src/api/java/appeng/api/networking/pathing/ControllerState.java index 98cd76548..0bb0e5e1a 100644 --- a/src/api/java/appeng/api/networking/pathing/ControllerState.java +++ b/src/api/java/appeng/api/networking/pathing/ControllerState.java @@ -23,6 +23,7 @@ package appeng.api.networking.pathing; + public enum ControllerState { /** diff --git a/src/api/java/appeng/api/networking/pathing/IPathingGrid.java b/src/api/java/appeng/api/networking/pathing/IPathingGrid.java index a8c94dfe2..f9a592eee 100644 --- a/src/api/java/appeng/api/networking/pathing/IPathingGrid.java +++ b/src/api/java/appeng/api/networking/pathing/IPathingGrid.java @@ -23,8 +23,10 @@ package appeng.api.networking.pathing; + import appeng.api.networking.IGridCache; + public interface IPathingGrid extends IGridCache { @@ -35,7 +37,7 @@ public interface IPathingGrid extends IGridCache /** * @return the controller state of the network, useful if you want to - * require a controller for a feature. + * require a controller for a feature. */ ControllerState getControllerState(); @@ -43,5 +45,4 @@ public interface IPathingGrid extends IGridCache * trigger a network reset, booting, path-finding and all. */ void repath(); - } \ No newline at end of file diff --git a/src/api/java/appeng/api/networking/security/BaseActionSource.java b/src/api/java/appeng/api/networking/security/BaseActionSource.java index aa18bf06f..bfaa66a24 100644 --- a/src/api/java/appeng/api/networking/security/BaseActionSource.java +++ b/src/api/java/appeng/api/networking/security/BaseActionSource.java @@ -23,6 +23,7 @@ package appeng.api.networking.security; + public class BaseActionSource { @@ -35,5 +36,4 @@ public class BaseActionSource { return false; } - } diff --git a/src/api/java/appeng/api/networking/security/IActionHost.java b/src/api/java/appeng/api/networking/security/IActionHost.java index d7eab6b3d..90c056d80 100644 --- a/src/api/java/appeng/api/networking/security/IActionHost.java +++ b/src/api/java/appeng/api/networking/security/IActionHost.java @@ -23,9 +23,11 @@ package appeng.api.networking.security; + import appeng.api.networking.IGridHost; import appeng.api.networking.IGridNode; + public interface IActionHost extends IGridHost { @@ -35,8 +37,7 @@ public interface IActionHost extends IGridHost * machine, unless the action is preformed by a non primary node. * * @return the the gridnode that actions from this IGridHost are preformed - * by. + * by. */ IGridNode getActionableNode(); - } diff --git a/src/api/java/appeng/api/networking/security/ISecurityGrid.java b/src/api/java/appeng/api/networking/security/ISecurityGrid.java index 3d428caa8..ad592e75e 100644 --- a/src/api/java/appeng/api/networking/security/ISecurityGrid.java +++ b/src/api/java/appeng/api/networking/security/ISecurityGrid.java @@ -23,7 +23,9 @@ package appeng.api.networking.security; + import net.minecraft.entity.player.EntityPlayer; + import appeng.api.config.SecurityPermissions; import appeng.api.networking.IGridCache; diff --git a/src/api/java/appeng/api/networking/security/ISecurityProvider.java b/src/api/java/appeng/api/networking/security/ISecurityProvider.java index ac3f7ac19..049d2e640 100644 --- a/src/api/java/appeng/api/networking/security/ISecurityProvider.java +++ b/src/api/java/appeng/api/networking/security/ISecurityProvider.java @@ -23,11 +23,13 @@ package appeng.api.networking.security; -import appeng.api.config.SecurityPermissions; import java.util.EnumSet; import java.util.HashMap; +import appeng.api.config.SecurityPermissions; + + /** * Implemented on Security Terminal to interface with security cache. */ @@ -46,7 +48,7 @@ public interface ISecurityProvider * * @param playerPerms player permissions */ - void readPermissions(HashMap> playerPerms); + void readPermissions( HashMap> playerPerms ); /** * @return is security on or off? @@ -57,5 +59,4 @@ public interface ISecurityProvider * @return player ID for who placed the security provider. */ int getOwner(); - } diff --git a/src/api/java/appeng/api/networking/security/ISecurityRegistry.java b/src/api/java/appeng/api/networking/security/ISecurityRegistry.java index 5b1103464..92a189735 100644 --- a/src/api/java/appeng/api/networking/security/ISecurityRegistry.java +++ b/src/api/java/appeng/api/networking/security/ISecurityRegistry.java @@ -23,10 +23,11 @@ package appeng.api.networking.security; -import appeng.api.config.SecurityPermissions; import java.util.EnumSet; +import appeng.api.config.SecurityPermissions; + /** * Used by vanilla Security Terminal to post biometric data into the security cache. */ diff --git a/src/api/java/appeng/api/networking/security/MachineSource.java b/src/api/java/appeng/api/networking/security/MachineSource.java index f3aa2a92f..e781a413a 100644 --- a/src/api/java/appeng/api/networking/security/MachineSource.java +++ b/src/api/java/appeng/api/networking/security/MachineSource.java @@ -23,6 +23,7 @@ package appeng.api.networking.security; + public class MachineSource extends BaseActionSource { @@ -34,8 +35,8 @@ public class MachineSource extends BaseActionSource return true; } - public MachineSource(IActionHost v) { + public MachineSource( IActionHost v ) + { this.via = v; } - } diff --git a/src/api/java/appeng/api/networking/security/PlayerSource.java b/src/api/java/appeng/api/networking/security/PlayerSource.java index 877fce02d..66c7c056d 100644 --- a/src/api/java/appeng/api/networking/security/PlayerSource.java +++ b/src/api/java/appeng/api/networking/security/PlayerSource.java @@ -23,8 +23,10 @@ package appeng.api.networking.security; + import net.minecraft.entity.player.EntityPlayer; + public class PlayerSource extends BaseActionSource { @@ -37,9 +39,9 @@ public class PlayerSource extends BaseActionSource return true; } - public PlayerSource(EntityPlayer p, IActionHost v) { + public PlayerSource( EntityPlayer p, IActionHost v ) + { this.player = p; this.via = v; } - } diff --git a/src/api/java/appeng/api/networking/spatial/ISpatialCache.java b/src/api/java/appeng/api/networking/spatial/ISpatialCache.java index a1028c2f8..d70b9bdaa 100644 --- a/src/api/java/appeng/api/networking/spatial/ISpatialCache.java +++ b/src/api/java/appeng/api/networking/spatial/ISpatialCache.java @@ -23,9 +23,11 @@ package appeng.api.networking.spatial; + import appeng.api.networking.IGridCache; import appeng.api.util.DimensionalCoord; + public interface ISpatialCache extends IGridCache { @@ -58,5 +60,4 @@ public interface ISpatialCache extends IGridCache * @return current 100% - 0% efficiency. */ float currentEfficiency(); - } diff --git a/src/api/java/appeng/api/networking/storage/IBaseMonitor.java b/src/api/java/appeng/api/networking/storage/IBaseMonitor.java index ed4c83c25..2d906ee32 100644 --- a/src/api/java/appeng/api/networking/storage/IBaseMonitor.java +++ b/src/api/java/appeng/api/networking/storage/IBaseMonitor.java @@ -23,20 +23,21 @@ package appeng.api.networking.storage; + import appeng.api.storage.IMEMonitorHandlerReceiver; import appeng.api.storage.data.IAEStack; + public interface IBaseMonitor { /** * add a new Listener to the monitor, be sure to properly remove yourself when your done. */ - void addListener(IMEMonitorHandlerReceiver l, Object verificationToken); + void addListener( IMEMonitorHandlerReceiver l, Object verificationToken ); /** * remove a Listener to the monitor. */ - void removeListener(IMEMonitorHandlerReceiver l); - + void removeListener( IMEMonitorHandlerReceiver l ); } diff --git a/src/api/java/appeng/api/networking/storage/IStackWatcher.java b/src/api/java/appeng/api/networking/storage/IStackWatcher.java index 942191a35..9d99a39dd 100644 --- a/src/api/java/appeng/api/networking/storage/IStackWatcher.java +++ b/src/api/java/appeng/api/networking/storage/IStackWatcher.java @@ -23,10 +23,12 @@ package appeng.api.networking.storage; + import java.util.Collection; import appeng.api.storage.data.IAEStack; + public interface IStackWatcher extends Collection { diff --git a/src/api/java/appeng/api/networking/ticking/TickRateModulation.java b/src/api/java/appeng/api/networking/ticking/TickRateModulation.java index 879744461..35e83b921 100644 --- a/src/api/java/appeng/api/networking/ticking/TickRateModulation.java +++ b/src/api/java/appeng/api/networking/ticking/TickRateModulation.java @@ -23,6 +23,7 @@ package appeng.api.networking.ticking; + public enum TickRateModulation { /** diff --git a/src/api/java/appeng/api/package-info.java b/src/api/java/appeng/api/package-info.java index 6d1f30422..a49bfd444 100644 --- a/src/api/java/appeng/api/package-info.java +++ b/src/api/java/appeng/api/package-info.java @@ -21,8 +21,8 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -@API(apiVersion = "rv2", owner = "appliedenergistics2", provides = "appliedenergistics2|API") -package appeng.api; +@API( apiVersion = "rv2", owner = "appliedenergistics2", provides = "appliedenergistics2|API" ) package appeng.api; + import cpw.mods.fml.common.API; diff --git a/src/api/java/appeng/api/parts/BusSupport.java b/src/api/java/appeng/api/parts/BusSupport.java index 52e05daba..03c54de41 100644 --- a/src/api/java/appeng/api/parts/BusSupport.java +++ b/src/api/java/appeng/api/parts/BusSupport.java @@ -23,6 +23,7 @@ package appeng.api.parts; + public enum BusSupport { CABLE, diff --git a/src/api/java/appeng/api/parts/CableRenderMode.java b/src/api/java/appeng/api/parts/CableRenderMode.java index 99eadcdab..e3505d999 100644 --- a/src/api/java/appeng/api/parts/CableRenderMode.java +++ b/src/api/java/appeng/api/parts/CableRenderMode.java @@ -23,17 +23,18 @@ package appeng.api.parts; + public enum CableRenderMode { + Standard( false ), - Standard(false), - - CableView(true); + CableView( true ); public final boolean transparentFacades; public final boolean opaqueFacades; - CableRenderMode( boolean hideFacades ) { + CableRenderMode( boolean hideFacades ) + { this.transparentFacades = hideFacades; this.opaqueFacades = !hideFacades; } diff --git a/src/api/java/appeng/api/parts/IAlphaPassItem.java b/src/api/java/appeng/api/parts/IAlphaPassItem.java index b4b37125f..f6bccaecb 100644 --- a/src/api/java/appeng/api/parts/IAlphaPassItem.java +++ b/src/api/java/appeng/api/parts/IAlphaPassItem.java @@ -23,8 +23,10 @@ package appeng.api.parts; + import net.minecraft.item.ItemStack; + public interface IAlphaPassItem { @@ -32,8 +34,8 @@ public interface IAlphaPassItem * Extend, and return true to enable a second pass for your parts in the bus rendering pipe line. * * @param is item + * * @return true to enable a second pass for your parts in the bus rendering pipe line. */ - boolean useAlphaPass(ItemStack is); - + boolean useAlphaPass( ItemStack is ); } diff --git a/src/api/java/appeng/api/parts/IBoxProvider.java b/src/api/java/appeng/api/parts/IBoxProvider.java index 657e0c475..a03230ef1 100644 --- a/src/api/java/appeng/api/parts/IBoxProvider.java +++ b/src/api/java/appeng/api/parts/IBoxProvider.java @@ -23,6 +23,7 @@ package appeng.api.parts; + public interface IBoxProvider { @@ -31,6 +32,5 @@ public interface IBoxProvider * * @param boxes collision boxes */ - void getBoxes(IPartCollisionHelper boxes); - + void getBoxes( IPartCollisionHelper boxes ); } diff --git a/src/api/java/appeng/api/parts/IFacadeContainer.java b/src/api/java/appeng/api/parts/IFacadeContainer.java index 33ad570f3..27fe0e15e 100644 --- a/src/api/java/appeng/api/parts/IFacadeContainer.java +++ b/src/api/java/appeng/api/parts/IFacadeContainer.java @@ -23,12 +23,14 @@ package appeng.api.parts; -import io.netty.buffer.ByteBuf; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; import java.io.IOException; +import io.netty.buffer.ByteBuf; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + /** * Used Internally. * diff --git a/src/api/java/appeng/api/parts/IFacadePart.java b/src/api/java/appeng/api/parts/IFacadePart.java index 4a200d168..bdab0cf21 100644 --- a/src/api/java/appeng/api/parts/IFacadePart.java +++ b/src/api/java/appeng/api/parts/IFacadePart.java @@ -23,12 +23,14 @@ package appeng.api.parts; + import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.entity.Entity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; diff --git a/src/api/java/appeng/api/parts/IPart.java b/src/api/java/appeng/api/parts/IPart.java index 808269549..add472c81 100644 --- a/src/api/java/appeng/api/parts/IPart.java +++ b/src/api/java/appeng/api/parts/IPart.java @@ -23,10 +23,13 @@ package appeng.api.parts; -import appeng.api.networking.IGridNode; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; + +import java.io.IOException; +import java.util.List; +import java.util.Random; + import io.netty.buffer.ByteBuf; + import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -39,9 +42,11 @@ import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.io.IOException; -import java.util.List; -import java.util.Random; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import appeng.api.networking.IGridNode; + public interface IPart extends IBoxProvider { @@ -58,7 +63,7 @@ public interface IPart extends IBoxProvider * * @return item of part */ - ItemStack getItemStack(PartItemStack type); + ItemStack getItemStack( PartItemStack type ); /** * render item form for inventory, or entity. @@ -68,42 +73,42 @@ public interface IPart extends IBoxProvider * @param rh helper * @param renderer renderer */ - @SideOnly(Side.CLIENT) - void renderInventory(IPartRenderHelper rh, RenderBlocks renderer); + @SideOnly( Side.CLIENT ) + void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ); /** * render world renderer ( preferred ) * * GL is NOT Available * - * @param x x coord - * @param y y coord - * @param z z coord - * @param rh helper + * @param x x coord + * @param y y coord + * @param z z coord + * @param rh helper * @param renderer renderer */ - @SideOnly(Side.CLIENT) - void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer); + @SideOnly( Side.CLIENT ) + void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ); /** * render TESR. * * GL Available * - * @param x x coord - * @param y y coord - * @param z z coord - * @param rh helper + * @param x x coord + * @param y y coord + * @param z z coord + * @param rh helper * @param renderer renderer */ - @SideOnly(Side.CLIENT) - void renderDynamic(double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer); + @SideOnly( Side.CLIENT ) + void renderDynamic( double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer ); /** * @return the Block sheet icon used when rendering the breaking particles, return null to use the ItemStack * texture. */ - @SideOnly(Side.CLIENT) + @SideOnly( Side.CLIENT ) IIcon getBreakingTexture(); /** @@ -129,14 +134,14 @@ public interface IPart extends IBoxProvider * * @param data to be written nbt data */ - void writeToNBT(NBTTagCompound data); + void writeToNBT( NBTTagCompound data ); /** * Read the previously written NBT Data. this is the mirror for writeToNBT * * @param data to be read nbt data */ - void readFromNBT(NBTTagCompound data); + void readFromNBT( NBTTagCompound data ); /** * @return get the amount of light produced by the bus @@ -150,7 +155,7 @@ public interface IPart extends IBoxProvider * * @return true if entity can climb */ - boolean isLadder(EntityLivingBase entity); + boolean isLadder( EntityLivingBase entity ); /** * a block around the bus's host has been changed. @@ -174,7 +179,7 @@ public interface IPart extends IBoxProvider * * @throws IOException */ - void writeToStream(ByteBuf data) throws IOException; + void writeToStream( ByteBuf data ) throws IOException; /** * read data from bus packet. @@ -185,7 +190,7 @@ public interface IPart extends IBoxProvider * * @throws IOException */ - boolean readFromStream(ByteBuf data) throws IOException; + boolean readFromStream( ByteBuf data ) throws IOException; /** * get the Grid Node for the Bus, be sure your IGridBlock is NOT isWorldAccessible, if it is your going to cause @@ -202,7 +207,7 @@ public interface IPart extends IBoxProvider * * @param entity colliding entity */ - void onEntityCollision(Entity entity); + void onEntityCollision( Entity entity ); /** * called when your part is being removed from the world. @@ -228,36 +233,36 @@ public interface IPart extends IBoxProvider * @param host part side * @param tile tile entity of part */ - void setPartHostInfo(ForgeDirection side, IPartHost host, TileEntity tile); + void setPartHostInfo( ForgeDirection side, IPartHost host, TileEntity tile ); /** * Called when you right click the part, very similar to Block.onActivateBlock * * @param player right clicking player - * @param pos position of block + * @param pos position of block * * @return if your activate method performed something. */ - boolean onActivate(EntityPlayer player, Vec3 pos); + boolean onActivate( EntityPlayer player, Vec3 pos ); /** * Called when you right click the part, very similar to Block.onActivateBlock * * @param player shift right clicking player - * @param pos position of block + * @param pos position of block * * @return if your activate method performed something, you should use false unless you really need it. */ - boolean onShiftActivate(EntityPlayer player, Vec3 pos); + boolean onShiftActivate( EntityPlayer player, Vec3 pos ); /** * Add drops to the items being dropped into the world, if your item stores its contents when wrenched use the * wrenched boolean to control what data is saved vs dropped when it is broken. * - * @param drops item drops if wrenched + * @param drops item drops if wrenched * @param wrenched control flag for wrenched vs broken */ - void getDrops(List drops, boolean wrenched); + void getDrops( List drops, boolean wrenched ); /** * @return 0 - 8, reasonable default 3-4, this controls the cable connection to the node. @@ -268,21 +273,21 @@ public interface IPart extends IBoxProvider * same as Block.randomDisplayTick, for but parts. * * @param world world of block - * @param x x coord of block - * @param y y coord of block - * @param z z coord of block - * @param r random + * @param x x coord of block + * @param y y coord of block + * @param z z coord of block + * @param r random */ - void randomDisplayTick(World world, int x, int y, int z, Random r); + void randomDisplayTick( World world, int x, int y, int z, Random r ); /** * Called when placed in the world by a player, this happens before addWorld. * * @param player placing player - * @param held held item - * @param side placing side + * @param held held item + * @param side placing side */ - void onPlacement(EntityPlayer player, ItemStack held, ForgeDirection side); + void onPlacement( EntityPlayer player, ItemStack held, ForgeDirection side ); /** * Used to determine which parts can be placed on what cables. @@ -291,6 +296,5 @@ public interface IPart extends IBoxProvider * * @return true if the part can be placed on this support. */ - boolean canBePlacedOn(BusSupport what); - + boolean canBePlacedOn( BusSupport what ); } \ No newline at end of file diff --git a/src/api/java/appeng/api/parts/IPartHost.java b/src/api/java/appeng/api/parts/IPartHost.java index f8a92ed04..e85661591 100644 --- a/src/api/java/appeng/api/parts/IPartHost.java +++ b/src/api/java/appeng/api/parts/IPartHost.java @@ -23,15 +23,17 @@ package appeng.api.parts; -import appeng.api.util.AEColor; -import appeng.api.util.DimensionalCoord; + +import java.util.Set; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Vec3; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Set; +import appeng.api.util.AEColor; +import appeng.api.util.DimensionalCoord; /** * Implemented on AE's TileEntity or AE's FMP Part. diff --git a/src/api/java/appeng/api/parts/IPartItem.java b/src/api/java/appeng/api/parts/IPartItem.java index d159baa92..019fcf2b7 100644 --- a/src/api/java/appeng/api/parts/IPartItem.java +++ b/src/api/java/appeng/api/parts/IPartItem.java @@ -23,8 +23,10 @@ package appeng.api.parts; + import net.minecraft.item.ItemStack; + //@formatter:off /** * This is a pretty basic requirement, once you implement the interface, and createPartFromItemStack @@ -58,8 +60,8 @@ public interface IPartItem * create a new part INSTANCE, from the item stack. * * @param is item + * * @return part from item */ - IPart createPartFromItemStack(ItemStack is); - + IPart createPartFromItemStack( ItemStack is ); } diff --git a/src/api/java/appeng/api/parts/IPartRenderHelper.java b/src/api/java/appeng/api/parts/IPartRenderHelper.java index 5f43d27a0..c107df082 100644 --- a/src/api/java/appeng/api/parts/IPartRenderHelper.java +++ b/src/api/java/appeng/api/parts/IPartRenderHelper.java @@ -23,14 +23,16 @@ package appeng.api.parts; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; + +import java.util.EnumSet; + import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.util.IIcon; import net.minecraftforge.common.util.ForgeDirection; -import java.util.EnumSet; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public interface IPartRenderHelper { diff --git a/src/api/java/appeng/api/parts/LayerBase.java b/src/api/java/appeng/api/parts/LayerBase.java index d2d2169ba..a89bc007a 100644 --- a/src/api/java/appeng/api/parts/LayerBase.java +++ b/src/api/java/appeng/api/parts/LayerBase.java @@ -23,11 +23,12 @@ package appeng.api.parts; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; import java.util.Set; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + /** * All Layers must extends this, this get part implementation is provided to interface with the parts, however a real * implementation will be used at runtime. diff --git a/src/api/java/appeng/api/parts/LayerFlags.java b/src/api/java/appeng/api/parts/LayerFlags.java index 50170a3ad..af04459bd 100644 --- a/src/api/java/appeng/api/parts/LayerFlags.java +++ b/src/api/java/appeng/api/parts/LayerFlags.java @@ -23,6 +23,7 @@ package appeng.api.parts; + public enum LayerFlags { diff --git a/src/api/java/appeng/api/parts/PartItemStack.java b/src/api/java/appeng/api/parts/PartItemStack.java index 2379bf5d7..795dd4917 100644 --- a/src/api/java/appeng/api/parts/PartItemStack.java +++ b/src/api/java/appeng/api/parts/PartItemStack.java @@ -23,6 +23,7 @@ package appeng.api.parts; + public enum PartItemStack { Pick, diff --git a/src/api/java/appeng/api/parts/SelectedPart.java b/src/api/java/appeng/api/parts/SelectedPart.java index 05a22f6d3..c5ec7f2fb 100644 --- a/src/api/java/appeng/api/parts/SelectedPart.java +++ b/src/api/java/appeng/api/parts/SelectedPart.java @@ -23,8 +23,10 @@ package appeng.api.parts; + import net.minecraftforge.common.util.ForgeDirection; + /** * Reports a selected part from th IPartHost */ @@ -46,22 +48,24 @@ public class SelectedPart */ public final ForgeDirection side; - public SelectedPart() { + public SelectedPart() + { this.part = null; this.facade = null; this.side = ForgeDirection.UNKNOWN; } - public SelectedPart(IPart part, ForgeDirection side) { + public SelectedPart( IPart part, ForgeDirection side ) + { this.part = part; this.facade = null; this.side = side; } - public SelectedPart(IFacadePart facade, ForgeDirection side) { + public SelectedPart( IFacadePart facade, ForgeDirection side ) + { this.part = null; this.facade = facade; this.side = side; } - } diff --git a/src/api/java/appeng/api/recipes/IRecipeHandler.java b/src/api/java/appeng/api/recipes/IRecipeHandler.java index 6de1a05fe..5c7b32e06 100644 --- a/src/api/java/appeng/api/recipes/IRecipeHandler.java +++ b/src/api/java/appeng/api/recipes/IRecipeHandler.java @@ -23,6 +23,7 @@ package appeng.api.recipes; + /** * Represents the AE2 Recipe Loading/Reading Class */ @@ -33,13 +34,12 @@ public interface IRecipeHandler * Call when you want to read recipes in from a file based on a loader * * @param loader recipe loader - * @param path path of file + * @param path path of file */ - void parseRecipes(IRecipeLoader loader, String path); + void parseRecipes( IRecipeLoader loader, String path ); /** * this loads the read recipes into minecraft, should be called in Init. */ void injectRecipes(); - } diff --git a/src/api/java/appeng/api/recipes/IRecipeLoader.java b/src/api/java/appeng/api/recipes/IRecipeLoader.java index 3feac0b0a..0e05c745e 100644 --- a/src/api/java/appeng/api/recipes/IRecipeLoader.java +++ b/src/api/java/appeng/api/recipes/IRecipeLoader.java @@ -23,11 +23,12 @@ package appeng.api.recipes; + import java.io.BufferedReader; + public interface IRecipeLoader { - BufferedReader getFile(String s) throws Exception; - + BufferedReader getFile( String s ) throws Exception; } diff --git a/src/api/java/appeng/api/recipes/ISubItemResolver.java b/src/api/java/appeng/api/recipes/ISubItemResolver.java index 5f5c28ca2..3e9c473a0 100644 --- a/src/api/java/appeng/api/recipes/ISubItemResolver.java +++ b/src/api/java/appeng/api/recipes/ISubItemResolver.java @@ -23,14 +23,14 @@ package appeng.api.recipes; + public interface ISubItemResolver { - /** * @param namespace namespace of sub item - * @param fullName name of sub item + * @param fullName name of sub item + * * @return either a ResolveResult, or a ResolverResultSet */ Object resolveItemByName( String namespace, String fullName ); - } diff --git a/src/api/java/appeng/api/recipes/ResolverResult.java b/src/api/java/appeng/api/recipes/ResolverResult.java index 1b104faa3..4141f510a 100644 --- a/src/api/java/appeng/api/recipes/ResolverResult.java +++ b/src/api/java/appeng/api/recipes/ResolverResult.java @@ -23,8 +23,10 @@ package appeng.api.recipes; + import net.minecraft.nbt.NBTTagCompound; + public class ResolverResult { @@ -32,16 +34,17 @@ public class ResolverResult final public int damageValue; final public NBTTagCompound compound; - public ResolverResult(String name, int damage) { + public ResolverResult( String name, int damage ) + { this.itemName = name; this.damageValue = damage; this.compound = null; } - public ResolverResult(String name, int damage, NBTTagCompound data) { + public ResolverResult( String name, int damage, NBTTagCompound data ) + { this.itemName = name; this.damageValue = damage; this.compound = data; } - } diff --git a/src/api/java/appeng/api/recipes/ResolverResultSet.java b/src/api/java/appeng/api/recipes/ResolverResultSet.java index 2ff5e7854..884b0f10b 100644 --- a/src/api/java/appeng/api/recipes/ResolverResultSet.java +++ b/src/api/java/appeng/api/recipes/ResolverResultSet.java @@ -23,20 +23,22 @@ package appeng.api.recipes; + import java.util.Arrays; import java.util.List; import net.minecraft.item.ItemStack; + public class ResolverResultSet { public final String name; public final List results; - public ResolverResultSet(String myName, ItemStack... set) { + public ResolverResultSet( String myName, ItemStack... set ) + { this.results = Arrays.asList( set ); this.name = myName; } - } diff --git a/src/api/java/appeng/api/storage/ICellContainer.java b/src/api/java/appeng/api/storage/ICellContainer.java index 7f558aada..4445dd3e4 100644 --- a/src/api/java/appeng/api/storage/ICellContainer.java +++ b/src/api/java/appeng/api/storage/ICellContainer.java @@ -23,8 +23,10 @@ package appeng.api.storage; + import appeng.api.networking.security.IActionHost; + /** * Represents an {@link appeng.api.networking.IGridHost} that contributes to storage, such as a ME Chest, or ME Drive. */ @@ -36,6 +38,5 @@ public interface ICellContainer extends IActionHost, ICellProvider, ISaveProvide * * @param slot slot index */ - void blinkCell(int slot); - + void blinkCell( int slot ); } diff --git a/src/api/java/appeng/api/storage/ICellHandler.java b/src/api/java/appeng/api/storage/ICellHandler.java index 77ffe9288..bec954dbb 100644 --- a/src/api/java/appeng/api/storage/ICellHandler.java +++ b/src/api/java/appeng/api/storage/ICellHandler.java @@ -23,13 +23,16 @@ package appeng.api.storage; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import appeng.api.implementations.tiles.IChestOrDrive; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import appeng.api.implementations.tiles.IChestOrDrive; + /** * Registration record for {@link ICellRegistry} */ diff --git a/src/api/java/appeng/api/storage/ICellInventory.java b/src/api/java/appeng/api/storage/ICellInventory.java index 2acdf93ea..13494b8d1 100644 --- a/src/api/java/appeng/api/storage/ICellInventory.java +++ b/src/api/java/appeng/api/storage/ICellInventory.java @@ -23,11 +23,14 @@ package appeng.api.storage; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; + import appeng.api.config.FuzzyMode; import appeng.api.storage.data.IAEItemStack; + public interface ICellInventory extends IMEInventory { @@ -115,5 +118,4 @@ public interface ICellInventory extends IMEInventory * @return the status number for this drive. */ int getStatusForCell(); - } diff --git a/src/api/java/appeng/api/storage/ICellInventoryHandler.java b/src/api/java/appeng/api/storage/ICellInventoryHandler.java index 9cff0585a..3f1e77ad9 100644 --- a/src/api/java/appeng/api/storage/ICellInventoryHandler.java +++ b/src/api/java/appeng/api/storage/ICellInventoryHandler.java @@ -23,9 +23,11 @@ package appeng.api.storage; + import appeng.api.config.IncludeExclude; import appeng.api.storage.data.IAEItemStack; + public interface ICellInventoryHandler extends IMEInventoryHandler { @@ -39,5 +41,4 @@ public interface ICellInventoryHandler extends IMEInventoryHandler boolean isFuzzy(); IncludeExclude getIncludeExcludeMode(); - } diff --git a/src/api/java/appeng/api/storage/ICellRegistry.java b/src/api/java/appeng/api/storage/ICellRegistry.java index 3204cf229..2b5aa7f47 100644 --- a/src/api/java/appeng/api/storage/ICellRegistry.java +++ b/src/api/java/appeng/api/storage/ICellRegistry.java @@ -23,7 +23,9 @@ package appeng.api.storage; + import net.minecraft.item.ItemStack; + import appeng.api.IAppEngApi; /** diff --git a/src/api/java/appeng/api/storage/ICellWorkbenchItem.java b/src/api/java/appeng/api/storage/ICellWorkbenchItem.java index 6a397d5b4..386893e24 100644 --- a/src/api/java/appeng/api/storage/ICellWorkbenchItem.java +++ b/src/api/java/appeng/api/storage/ICellWorkbenchItem.java @@ -23,8 +23,10 @@ package appeng.api.storage; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; + import appeng.api.config.FuzzyMode; public interface ICellWorkbenchItem diff --git a/src/api/java/appeng/api/storage/IExternalStorageHandler.java b/src/api/java/appeng/api/storage/IExternalStorageHandler.java index b8ad9dee8..d5ae652fb 100644 --- a/src/api/java/appeng/api/storage/IExternalStorageHandler.java +++ b/src/api/java/appeng/api/storage/IExternalStorageHandler.java @@ -23,8 +23,10 @@ package appeng.api.storage; + import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; + import appeng.api.networking.security.BaseActionSource; /** diff --git a/src/api/java/appeng/api/storage/IExternalStorageRegistry.java b/src/api/java/appeng/api/storage/IExternalStorageRegistry.java index 338f39965..fb7955e0c 100644 --- a/src/api/java/appeng/api/storage/IExternalStorageRegistry.java +++ b/src/api/java/appeng/api/storage/IExternalStorageRegistry.java @@ -23,8 +23,10 @@ package appeng.api.storage; + import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; + import appeng.api.IAppEngApi; import appeng.api.networking.security.BaseActionSource; diff --git a/src/api/java/appeng/api/storage/IMEMonitor.java b/src/api/java/appeng/api/storage/IMEMonitor.java index cdee632d0..752691e2f 100644 --- a/src/api/java/appeng/api/storage/IMEMonitor.java +++ b/src/api/java/appeng/api/storage/IMEMonitor.java @@ -23,10 +23,12 @@ package appeng.api.storage; + import appeng.api.networking.storage.IBaseMonitor; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; + public interface IMEMonitor extends IMEInventoryHandler, IBaseMonitor { @@ -43,5 +45,4 @@ public interface IMEMonitor extends IMEInventoryHandler, * @return full storage list. */ IItemList getStorageList(); - } diff --git a/src/api/java/appeng/api/storage/IMEMonitorHandlerReceiver.java b/src/api/java/appeng/api/storage/IMEMonitorHandlerReceiver.java index a7e8d4ead..30bbb7451 100644 --- a/src/api/java/appeng/api/storage/IMEMonitorHandlerReceiver.java +++ b/src/api/java/appeng/api/storage/IMEMonitorHandlerReceiver.java @@ -23,10 +23,12 @@ package appeng.api.storage; + import appeng.api.networking.security.BaseActionSource; import appeng.api.networking.storage.IBaseMonitor; import appeng.api.storage.data.IAEStack; + public interface IMEMonitorHandlerReceiver { @@ -34,20 +36,20 @@ public interface IMEMonitorHandlerReceiver * return true if this object should remain as a listener. * * @param verificationToken to be checked object + * * @return true if object should remain as a listener */ - boolean isValid(Object verificationToken); + boolean isValid( Object verificationToken ); /** * called when changes are made to the Monitor, but only if listener is still valid. * * @param change done change */ - void postChange(IBaseMonitor monitor, Iterable change, BaseActionSource actionSource); + void postChange( IBaseMonitor monitor, Iterable change, BaseActionSource actionSource ); /** * called when the list updates its contents, this is mostly for handling power events. */ void onListUpdate(); - } diff --git a/src/api/java/appeng/api/storage/ISaveProvider.java b/src/api/java/appeng/api/storage/ISaveProvider.java index b3c6f4b34..7c046826c 100644 --- a/src/api/java/appeng/api/storage/ISaveProvider.java +++ b/src/api/java/appeng/api/storage/ISaveProvider.java @@ -27,6 +27,5 @@ package appeng.api.storage; public interface ISaveProvider { - void saveChanges(IMEInventory cellInventory); - + void saveChanges( IMEInventory cellInventory ); } diff --git a/src/api/java/appeng/api/storage/IStorageHelper.java b/src/api/java/appeng/api/storage/IStorageHelper.java index 8e935fa65..fa8693c5a 100644 --- a/src/api/java/appeng/api/storage/IStorageHelper.java +++ b/src/api/java/appeng/api/storage/IStorageHelper.java @@ -23,6 +23,15 @@ package appeng.api.storage; + +import java.io.IOException; + +import io.netty.buffer.ByteBuf; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + import appeng.api.networking.crafting.ICraftingLink; import appeng.api.networking.crafting.ICraftingRequester; import appeng.api.networking.energy.IEnergySource; @@ -30,12 +39,6 @@ import appeng.api.networking.security.BaseActionSource; import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; -import io.netty.buffer.ByteBuf; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.FluidStack; - -import java.io.IOException; public interface IStorageHelper { diff --git a/src/api/java/appeng/api/storage/ITerminalHost.java b/src/api/java/appeng/api/storage/ITerminalHost.java index 8b87d7246..f802b6d65 100644 --- a/src/api/java/appeng/api/storage/ITerminalHost.java +++ b/src/api/java/appeng/api/storage/ITerminalHost.java @@ -23,8 +23,10 @@ package appeng.api.storage; + import appeng.api.util.IConfigurableObject; + public interface ITerminalHost extends IStorageMonitorable, IConfigurableObject { diff --git a/src/api/java/appeng/api/storage/MEMonitorHandler.java b/src/api/java/appeng/api/storage/MEMonitorHandler.java index 99948954d..733a11cf3 100644 --- a/src/api/java/appeng/api/storage/MEMonitorHandler.java +++ b/src/api/java/appeng/api/storage/MEMonitorHandler.java @@ -23,16 +23,18 @@ package appeng.api.storage; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +import com.google.common.collect.ImmutableList; + import appeng.api.config.AccessRestriction; import appeng.api.config.Actionable; import appeng.api.networking.security.BaseActionSource; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; -import com.google.common.collect.ImmutableList; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map.Entry; /** * Common implementation of a simple class that monitors injection/extraction of a inventory to send events to a list of diff --git a/src/api/java/appeng/api/storage/StorageChannel.java b/src/api/java/appeng/api/storage/StorageChannel.java index 73c05c06d..faaba20b9 100644 --- a/src/api/java/appeng/api/storage/StorageChannel.java +++ b/src/api/java/appeng/api/storage/StorageChannel.java @@ -23,12 +23,14 @@ package appeng.api.storage; + import appeng.api.AEApi; import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; + public enum StorageChannel { /** @@ -43,11 +45,13 @@ public enum StorageChannel public final Class type; - StorageChannel( Class t ) { + StorageChannel( Class t ) + { this.type = t; } - public IItemList createList() { + public IItemList createList() + { if ( this == ITEMS ) return AEApi.instance().storage().createItemList(); else diff --git a/src/api/java/appeng/api/storage/data/IAEStack.java b/src/api/java/appeng/api/storage/data/IAEStack.java index b023411f9..b3c6aad8f 100644 --- a/src/api/java/appeng/api/storage/data/IAEStack.java +++ b/src/api/java/appeng/api/storage/data/IAEStack.java @@ -23,13 +23,16 @@ package appeng.api.storage.data; -import appeng.api.config.FuzzyMode; -import appeng.api.storage.StorageChannel; -import io.netty.buffer.ByteBuf; -import net.minecraft.nbt.NBTTagCompound; import java.io.IOException; +import io.netty.buffer.ByteBuf; + +import net.minecraft.nbt.NBTTagCompound; + +import appeng.api.config.FuzzyMode; +import appeng.api.storage.StorageChannel; + public interface IAEStack { diff --git a/src/api/java/appeng/api/util/AECableType.java b/src/api/java/appeng/api/util/AECableType.java index 64e8a49a4..5d6f3464a 100644 --- a/src/api/java/appeng/api/util/AECableType.java +++ b/src/api/java/appeng/api/util/AECableType.java @@ -23,6 +23,7 @@ package appeng.api.util; + public enum AECableType { /** diff --git a/src/api/java/appeng/api/util/AEColor.java b/src/api/java/appeng/api/util/AEColor.java index e025a8903..cc04fb27c 100644 --- a/src/api/java/appeng/api/util/AEColor.java +++ b/src/api/java/appeng/api/util/AEColor.java @@ -23,8 +23,13 @@ package appeng.api.util; + +import java.util.Arrays; +import java.util.List; + import net.minecraft.util.StatCollector; + /** * List of all colors supported by AE, their names, and various colors for display. * @@ -67,6 +72,8 @@ public enum AEColor Transparent("gui.appliedenergistics2.Fluix", 0x1B2344, 0x895CA8, 0xD7BBEC); + public static final List VALID_COLORS = Arrays.asList( White, Orange, Magenta, LightBlue, Yellow, Lime, Pink, Gray, LightGray, Cyan, Purple, Blue, Brown, Green, Red, Black ); + /** * Unlocalized name for color. */ diff --git a/src/api/java/appeng/api/util/AEColoredItemDefinition.java b/src/api/java/appeng/api/util/AEColoredItemDefinition.java index 29fe3824a..caf292a7d 100644 --- a/src/api/java/appeng/api/util/AEColoredItemDefinition.java +++ b/src/api/java/appeng/api/util/AEColoredItemDefinition.java @@ -23,48 +23,50 @@ package appeng.api.util; + import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; + public interface AEColoredItemDefinition { /** * @return the {@link Block} Implementation if applicable */ - Block block(AEColor color); + Block block( AEColor color ); /** * @return the {@link Item} Implementation if applicable */ - Item item(AEColor color); + Item item( AEColor color ); /** * @return the {@link TileEntity} Class if applicable. */ - Class entity(AEColor color); + Class entity( AEColor color ); /** * @return an {@link ItemStack} with specified quantity of this item. */ - ItemStack stack(AEColor color, int stackSize); + ItemStack stack( AEColor color, int stackSize ); /** - * @param stackSize - * - stack size of the result. + * @param stackSize - stack size of the result. + * * @return an array of all colors. */ - ItemStack[] allStacks(int stackSize); + ItemStack[] allStacks( int stackSize ); /** - * Compare {@link ItemStack} with this {@link AEItemDefinition} + * Compare {@link ItemStack} with this * - * @param color compared color of item + * @param color compared color of item * @param comparableItem compared item + * * @return true if the item stack is a matching item. */ - boolean sameAs(AEColor color, ItemStack comparableItem); - + boolean sameAs( AEColor color, ItemStack comparableItem ); } diff --git a/src/api/java/appeng/api/util/AEItemDefinition.java b/src/api/java/appeng/api/util/AEItemDefinition.java index 8874b7bdd..5ea619e46 100644 --- a/src/api/java/appeng/api/util/AEItemDefinition.java +++ b/src/api/java/appeng/api/util/AEItemDefinition.java @@ -23,55 +23,89 @@ package appeng.api.util; + +import javax.annotation.Nullable; + import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; +import appeng.api.definitions.IBlockDefinition; +import appeng.api.definitions.IComparableDefinition; +import appeng.api.definitions.IItemDefinition; +import appeng.api.definitions.ITileDefinition; + + /** * Gives easy access to different part of the various, items/blocks/materials in AE. + * + * @deprecated use {@link ITileDefinition} and its sub-classes */ +@Deprecated public interface AEItemDefinition { - /** * @return the {@link Block} Implementation if applicable + * + * @deprecated use {@link IBlockDefinition#maybeBlock()} */ + @Deprecated + @Nullable Block block(); /** * @return the {@link Item} Implementation if applicable + * + * @deprecated use {@link IItemDefinition#maybeItem()} */ + @Deprecated + @Nullable Item item(); /** * @return the {@link TileEntity} Class if applicable. + * + * @deprecated use {@link ITileDefinition#maybeEntity()} */ + @Deprecated + @Nullable Class entity(); /** * @return an {@link ItemStack} with specified quantity of this item. + * + * @deprecated use {@link IItemDefinition#maybeStack(int)} */ - ItemStack stack(int stackSize); + @Deprecated + @Nullable + ItemStack stack( int stackSize ); /** * Compare {@link ItemStack} with this * * @param comparableItem compared item + * * @return true if the item stack is a matching item. + * + * @deprecated use {@link IComparableDefinition#isSameAs(ItemStack)} */ - boolean sameAsStack(ItemStack comparableItem); + @Deprecated + boolean sameAsStack( ItemStack comparableItem ); /** * Compare Block with world. * * @param world world of block - * @param x x pos of block - * @param y y pos of block - * @param z z pos of block + * @param x x pos of block + * @param y y pos of block + * @param z z pos of block * * @return if the block is placed in the world at the specific location. + * + * @deprecated use {@link IComparableDefinition#isSameAs(IBlockAccess, int, int, int)} } */ - boolean sameAsBlock(IBlockAccess world, int x, int y, int z); + @Deprecated + boolean sameAsBlock( IBlockAccess world, int x, int y, int z ); } diff --git a/src/api/java/appeng/api/util/DimensionalCoord.java b/src/api/java/appeng/api/util/DimensionalCoord.java index ac9a39d5a..a78bc6078 100644 --- a/src/api/java/appeng/api/util/DimensionalCoord.java +++ b/src/api/java/appeng/api/util/DimensionalCoord.java @@ -23,9 +23,11 @@ package appeng.api.util; + import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; + /** * Represents a location in the Minecraft Universe */ @@ -35,19 +37,22 @@ public class DimensionalCoord extends WorldCoord private final World w; private final int dimId; - public DimensionalCoord(DimensionalCoord s) { + public DimensionalCoord( DimensionalCoord s ) + { super( s.x, s.y, s.z ); this.w = s.w; this.dimId = s.dimId; } - public DimensionalCoord(TileEntity s) { + public DimensionalCoord( TileEntity s ) + { super( s ); this.w = s.getWorldObj(); this.dimId = this.w.provider.dimensionId; } - public DimensionalCoord(World _w, int _x, int _y, int _z) { + public DimensionalCoord( World _w, int _x, int _y, int _z ) + { super( _x, _y, _z ); this.w = _w; this.dimId = _w.provider.dimensionId; @@ -59,15 +64,15 @@ public class DimensionalCoord extends WorldCoord return new DimensionalCoord( this ); } - public boolean isEqual(DimensionalCoord c) + public boolean isEqual( DimensionalCoord c ) { return this.x == c.x && this.y == c.y && this.z == c.z && c.w == this.w; } @Override - public boolean equals(Object obj) + public boolean equals( Object obj ) { - return obj instanceof DimensionalCoord && this.isEqual((DimensionalCoord) obj); + return obj instanceof DimensionalCoord && this.isEqual( (DimensionalCoord) obj ); } @Override @@ -76,7 +81,7 @@ public class DimensionalCoord extends WorldCoord return super.hashCode() ^ this.dimId; } - public boolean isInWorld(World world) + public boolean isInWorld( World world ) { return this.w == world; } diff --git a/src/api/java/appeng/api/util/ICommonTile.java b/src/api/java/appeng/api/util/ICommonTile.java index 62f83f447..ca87b4d1d 100644 --- a/src/api/java/appeng/api/util/ICommonTile.java +++ b/src/api/java/appeng/api/util/ICommonTile.java @@ -23,10 +23,12 @@ package appeng.api.util; + +import java.util.ArrayList; + import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import java.util.ArrayList; public interface ICommonTile { @@ -36,11 +38,10 @@ public interface ICommonTile * the block itself. * * @param world world of tile entity - * @param x x pos of tile entity - * @param y y pos of tile entity - * @param z z pos of tile entity + * @param x x pos of tile entity + * @param y y pos of tile entity + * @param z z pos of tile entity * @param drops drops of tile entity */ - void getDrops(World world, int x, int y, int z, ArrayList drops); - + void getDrops( World world, int x, int y, int z, ArrayList drops ); } \ No newline at end of file diff --git a/src/api/java/appeng/api/util/IConfigManager.java b/src/api/java/appeng/api/util/IConfigManager.java index 1162ada41..60026335c 100644 --- a/src/api/java/appeng/api/util/IConfigManager.java +++ b/src/api/java/appeng/api/util/IConfigManager.java @@ -23,10 +23,14 @@ package appeng.api.util; + import java.util.Set; import net.minecraft.nbt.NBTTagCompound; +import appeng.api.config.Settings; + + /** * Used to adjust settings on an object, * @@ -40,7 +44,7 @@ public interface IConfigManager * * @return enum set of settings */ - Set getSettings(); + Set getSettings(); /** * used to initialize the configuration manager, should be called for all settings. @@ -48,7 +52,7 @@ public interface IConfigManager * @param settingName name of setting * @param defaultValue default value of setting */ - void registerSetting(Enum settingName, Enum defaultValue); + void registerSetting(Settings settingName, Enum defaultValue); /** * Get Value of a particular setting @@ -56,7 +60,7 @@ public interface IConfigManager * @param settingName name of setting * @return value of setting */ - Enum getSetting(Enum settingName); + Enum getSetting(Settings settingName); /** * Change setting @@ -65,7 +69,7 @@ public interface IConfigManager * @param newValue new value for setting * @return changed setting */ - Enum putSetting(Enum settingName, Enum newValue); + Enum putSetting(Settings settingName, Enum newValue); /** * write all settings to the NBT Tag so they can be read later. diff --git a/src/api/java/appeng/api/util/IConfigurableObject.java b/src/api/java/appeng/api/util/IConfigurableObject.java index f87bf6a85..e25e74035 100644 --- a/src/api/java/appeng/api/util/IConfigurableObject.java +++ b/src/api/java/appeng/api/util/IConfigurableObject.java @@ -23,6 +23,7 @@ package appeng.api.util; + /** * Implemented by various Tiles or Parts in AE */ @@ -33,5 +34,4 @@ public interface IConfigurableObject * get the config manager for the object. */ IConfigManager getConfigManager(); - } diff --git a/src/api/java/appeng/api/util/INetworkToolAgent.java b/src/api/java/appeng/api/util/INetworkToolAgent.java index 8a73e65c6..915df02c5 100644 --- a/src/api/java/appeng/api/util/INetworkToolAgent.java +++ b/src/api/java/appeng/api/util/INetworkToolAgent.java @@ -23,14 +23,15 @@ package appeng.api.util; + import net.minecraft.util.MovingObjectPosition; + /** * Implement on Tile or part to customize if the info gui opens, or an action is preformed. */ public interface INetworkToolAgent { - boolean showNetworkInfo(MovingObjectPosition where); - + boolean showNetworkInfo( MovingObjectPosition where ); } diff --git a/src/api/java/appeng/api/util/IOrientableBlock.java b/src/api/java/appeng/api/util/IOrientableBlock.java index 795495f67..8081cd813 100644 --- a/src/api/java/appeng/api/util/IOrientableBlock.java +++ b/src/api/java/appeng/api/util/IOrientableBlock.java @@ -23,8 +23,10 @@ package appeng.api.util; + import net.minecraft.world.IBlockAccess; + /** * Implemented on many of AE's non Tile Entity Blocks as a way to get a IOrientable. */ @@ -38,11 +40,11 @@ public interface IOrientableBlock /** * @param world world of block - * @param x x pos of block - * @param y y pos of block - * @param z z pos of block + * @param x x pos of block + * @param y y pos of block + * @param z z pos of block + * * @return a IOrientable if applicable */ - IOrientable getOrientable(IBlockAccess world, int x, int y, int z); - + IOrientable getOrientable( IBlockAccess world, int x, int y, int z ); } \ No newline at end of file diff --git a/src/api/java/appeng/api/util/IReadOnlyCollection.java b/src/api/java/appeng/api/util/IReadOnlyCollection.java index 55ded3f96..84e042ae7 100644 --- a/src/api/java/appeng/api/util/IReadOnlyCollection.java +++ b/src/api/java/appeng/api/util/IReadOnlyCollection.java @@ -23,6 +23,7 @@ package appeng.api.util; + public interface IReadOnlyCollection extends Iterable { @@ -39,6 +40,5 @@ public interface IReadOnlyCollection extends Iterable /** * @return return true if the object is part of the set. */ - boolean contains(Object node); - + boolean contains( Object node ); } diff --git a/src/api/java/appeng/api/util/WorldCoord.java b/src/api/java/appeng/api/util/WorldCoord.java index 8b117f0ed..121c7c95e 100644 --- a/src/api/java/appeng/api/util/WorldCoord.java +++ b/src/api/java/appeng/api/util/WorldCoord.java @@ -23,9 +23,11 @@ package appeng.api.util; + import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; + /** * Represents a relative coordinate, either relative to another object, or * relative to the origin of a dimension. @@ -37,7 +39,7 @@ public class WorldCoord public int y; public int z; - public WorldCoord add(ForgeDirection direction, int length) + public WorldCoord add( ForgeDirection direction, int length ) { this.x += direction.offsetX * length; this.y += direction.offsetY * length; @@ -45,7 +47,7 @@ public class WorldCoord return this; } - public WorldCoord subtract(ForgeDirection direction, int length) + public WorldCoord subtract( ForgeDirection direction, int length ) { this.x -= direction.offsetX * length; this.y -= direction.offsetY * length; @@ -53,7 +55,7 @@ public class WorldCoord return this; } - public WorldCoord add(int _x, int _y, int _z) + public WorldCoord add( int _x, int _y, int _z ) { this.x += _x; this.y += _y; @@ -61,7 +63,7 @@ public class WorldCoord return this; } - public WorldCoord subtract(int _x, int _y, int _z) + public WorldCoord subtract( int _x, int _y, int _z ) { this.x -= _x; this.y -= _y; @@ -69,7 +71,7 @@ public class WorldCoord return this; } - public WorldCoord multiple(int _x, int _y, int _z) + public WorldCoord multiple( int _x, int _y, int _z ) { this.x *= _x; this.y *= _y; @@ -77,7 +79,7 @@ public class WorldCoord return this; } - public WorldCoord divide(int _x, int _y, int _z) + public WorldCoord divide( int _x, int _y, int _z ) { this.x /= _x; this.y /= _y; @@ -85,20 +87,22 @@ public class WorldCoord return this; } - public WorldCoord(int _x, int _y, int _z) { + public WorldCoord( int _x, int _y, int _z ) + { this.x = _x; this.y = _y; this.z = _z; } - public WorldCoord(TileEntity s) { + public WorldCoord( TileEntity s ) + { this( s.xCoord, s.yCoord, s.zCoord ); } /** * Will Return NULL if it's at some diagonal! */ - public ForgeDirection directionTo(WorldCoord loc) + public ForgeDirection directionTo( WorldCoord loc ) { int ox = this.x - loc.x; int oy = this.y - loc.y; @@ -129,7 +133,7 @@ public class WorldCoord return null; } - public boolean isEqual(WorldCoord c) + public boolean isEqual( WorldCoord c ) { return this.x == c.x && this.y == c.y && this.z == c.z; } @@ -140,9 +144,9 @@ public class WorldCoord } @Override - public boolean equals(Object obj) + public boolean equals( Object obj ) { - return obj instanceof WorldCoord && this.isEqual((WorldCoord) obj); + return obj instanceof WorldCoord && this.isEqual( (WorldCoord) obj ); } @Override @@ -154,6 +158,6 @@ public class WorldCoord @Override public int hashCode() { - return ( this.y << 24) ^ this.x ^ this.z; + return ( this.y << 24 ) ^ this.x ^ this.z; } } diff --git a/src/main/java/appeng/block/AEBaseItemBlockChargeable.java b/src/main/java/appeng/block/AEBaseItemBlockChargeable.java index df5016e06..9d06bb1e0 100644 --- a/src/main/java/appeng/block/AEBaseItemBlockChargeable.java +++ b/src/main/java/appeng/block/AEBaseItemBlockChargeable.java @@ -30,10 +30,11 @@ import net.minecraft.nbt.NBTTagCompound; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import appeng.api.AEApi; import appeng.api.config.AccessRestriction; import appeng.api.config.PowerUnits; +import appeng.api.definitions.IBlockDefinition; import appeng.api.implementations.items.IAEItemPowerStorage; +import appeng.core.Api; import appeng.core.localization.GuiText; import appeng.util.Platform; @@ -66,11 +67,21 @@ public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEIte private double getMaxEnergyCapacity() { - Block blk = Block.getBlockFromItem( this ); - if ( blk == AEApi.instance().blocks().blockEnergyCell.block() ) - return 200000; - else - return 8 * 200000; + Block blockID = Block.getBlockFromItem( this ); + final IBlockDefinition energyCell = Api.INSTANCE.definitions().blocks().energyCell(); + for ( Block block : energyCell.maybeBlock().asSet() ) + { + if ( blockID == block ) + { + return 200000; + } + else + { + return 8 * 200000; + } + } + + return 0; } private double getInternal(ItemStack is) diff --git a/src/main/java/appeng/block/crafting/BlockCraftingMonitor.java b/src/main/java/appeng/block/crafting/BlockCraftingMonitor.java index c1ec6ada0..1309b4a16 100644 --- a/src/main/java/appeng/block/crafting/BlockCraftingMonitor.java +++ b/src/main/java/appeng/block/crafting/BlockCraftingMonitor.java @@ -18,8 +18,10 @@ package appeng.block.crafting; + import java.util.List; +import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -35,15 +37,38 @@ import appeng.client.render.blocks.RenderBlockCraftingCPUMonitor; import appeng.client.texture.ExtraBlockTextures; import appeng.tile.crafting.TileCraftingMonitorTile; + public class BlockCraftingMonitor extends BlockCraftingUnit { - public BlockCraftingMonitor() { + public BlockCraftingMonitor() + { super( BlockCraftingMonitor.class ); this.setTileEntity( TileCraftingMonitorTile.class ); } + @Override + public IIcon getIcon( int direction, int metadata ) + { + if ( direction != ForgeDirection.SOUTH.ordinal() ) + { + for ( Block craftingUnitBlock : AEApi.instance().definitions().blocks().craftingUnit().maybeBlock().asSet() ) + { + return craftingUnitBlock.getIcon( direction, metadata ); + } + } + + switch ( metadata ) + { + default: + case 0: + return super.getIcon( 0, 0 ); + case FLAG_FORMED: + return ExtraBlockTextures.BlockCraftingMonitorFit_Light.getIcon(); + } + } + @Override protected Class getRenderer() { @@ -51,24 +76,8 @@ public class BlockCraftingMonitor extends BlockCraftingUnit } @Override - public IIcon getIcon(int direction, int metadata) - { - if ( direction != ForgeDirection.SOUTH.ordinal() ) - return AEApi.instance().blocks().blockCraftingUnit.block().getIcon( direction, metadata ); - - switch (metadata) - { - default: - case 0: - return super.getIcon( 0, 0 ); - case FLAG_FORMED: - return ExtraBlockTextures.BlockCraftingMonitorFit_Light.getIcon(); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void getCheckedSubBlocks(Item item, CreativeTabs tabs, List itemStacks) + @SideOnly( Side.CLIENT ) + public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List itemStacks ) { itemStacks.add( new ItemStack( this, 1, 0 ) ); } diff --git a/src/main/java/appeng/block/crafting/ItemCraftingStorage.java b/src/main/java/appeng/block/crafting/ItemCraftingStorage.java index f2f5dc111..c40146139 100644 --- a/src/main/java/appeng/block/crafting/ItemCraftingStorage.java +++ b/src/main/java/appeng/block/crafting/ItemCraftingStorage.java @@ -42,7 +42,11 @@ public class ItemCraftingStorage extends AEBaseItemBlock @Override public ItemStack getContainerItem(ItemStack itemStack) { - return AEApi.instance().blocks().blockCraftingUnit.stack( 1 ); - } + for ( ItemStack stack : AEApi.instance().definitions().blocks().craftingUnit().maybeStack( 1 ).asSet() ) + { + return stack; + } + return null; + } } diff --git a/src/main/java/appeng/block/misc/BlockCharger.java b/src/main/java/appeng/block/misc/BlockCharger.java index 2f8376a7f..3cfcfda80 100644 --- a/src/main/java/appeng/block/misc/BlockCharger.java +++ b/src/main/java/appeng/block/misc/BlockCharger.java @@ -97,9 +97,9 @@ public class BlockCharger extends AEBaseBlock implements ICustomCollision if ( tile instanceof TileCharger ) { TileCharger tc = (TileCharger) tile; - if ( AEApi.instance().materials().materialCertusQuartzCrystalCharged.sameAsStack( tc.getStackInSlot( 0 ) ) ) - { + if ( AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( tc.getStackInSlot( 0 ) ) ) + { double xOff = 0.0; double yOff = 0.0; double zOff = 0.0; @@ -112,7 +112,6 @@ public class BlockCharger extends AEBaseBlock implements ICustomCollision Minecraft.getMinecraft().effectRenderer.addEffect( fx ); } } - } } } diff --git a/src/main/java/appeng/block/networking/BlockCableBus.java b/src/main/java/appeng/block/networking/BlockCableBus.java index 5b1a408e0..a7bd72cfd 100644 --- a/src/main/java/appeng/block/networking/BlockCableBus.java +++ b/src/main/java/appeng/block/networking/BlockCableBus.java @@ -424,10 +424,10 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection public void setupTile() { - this.setTileEntity( noTesrTile = Api.INSTANCE.partHelper.getCombinedInstance( TileCableBus.class.getName() ) ); + this.setTileEntity( noTesrTile = Api.INSTANCE.getPartHelper().getCombinedInstance( TileCableBus.class.getName() ) ); if ( Platform.isClient() ) { - tesrTile = Api.INSTANCE.partHelper.getCombinedInstance( TileCableBusTESR.class.getName() ); + tesrTile = Api.INSTANCE.getPartHelper().getCombinedInstance( TileCableBusTESR.class.getName() ); GameRegistry.registerTileEntity( tesrTile, "ClientOnly_TESR_CableBus" ); CommonHelper.proxy.bindTileEntitySpecialRenderer( tesrTile, this ); } diff --git a/src/main/java/appeng/block/solids/OreQuartz.java b/src/main/java/appeng/block/solids/OreQuartz.java index 4e75f0376..77b742185 100644 --- a/src/main/java/appeng/block/solids/OreQuartz.java +++ b/src/main/java/appeng/block/solids/OreQuartz.java @@ -21,6 +21,8 @@ package appeng.block.solids; import java.util.EnumSet; import java.util.Random; +import javax.annotation.Nullable; + import net.minecraft.block.material.Material; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -30,6 +32,7 @@ import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; import appeng.api.AEApi; +import appeng.api.exceptions.MissingDefinition; import appeng.block.AEBaseBlock; import appeng.client.render.BaseBlockRender; import appeng.client.render.blocks.RenderQuartzOre; @@ -37,12 +40,11 @@ import appeng.core.features.AEFeature; public class OreQuartz extends AEBaseBlock { + private int boostBrightnessLow; + private int boostBrightnessHigh; + private boolean enhanceBrightness; - public int boostBrightnessLow; - public int boostBrightnessHigh; - public boolean enhanceBrightness; - - public OreQuartz(Class self) { + public OreQuartz(Class self) { super( self, Material.rock ); this.setFeature( EnumSet.of( AEFeature.Core ) ); this.setHardness( 3.0F ); @@ -73,9 +75,13 @@ public class OreQuartz extends AEBaseBlock j1 = Math.max( j1 >> 20, j1 >> 4 ); if ( j1 > 4 ) + { j1 += this.boostBrightnessHigh; + } else + { j1 += this.boostBrightnessLow; + } if ( j1 > 15 ) j1 = 15; @@ -88,21 +94,27 @@ public class OreQuartz extends AEBaseBlock this( OreQuartz.class ); } - ItemStack getItemDropped() - { - return AEApi.instance().materials().materialCertusQuartzCrystal.stack( 1 ); - } - + @Nullable @Override public Item getItemDropped(int id, Random rand, int meta) { - return this.getItemDropped().getItem(); + for ( Item crystalItem : AEApi.instance().definitions().materials().certusQuartzCrystal().maybeItem().asSet() ) + { + return crystalItem; + } + + throw new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" ); } @Override public int damageDropped(int id) { - return this.getItemDropped().getItemDamage(); + for ( ItemStack crystalStack : AEApi.instance().definitions().materials().certusQuartzCrystal().maybeStack( 1 ).asSet() ) + { + return crystalStack.getItemDamage(); + } + + throw new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" ); } @Override @@ -144,4 +156,18 @@ public class OreQuartz extends AEBaseBlock } } + public void setBoostBrightnessLow( int boostBrightnessLow ) + { + this.boostBrightnessLow = boostBrightnessLow; + } + + public void setBoostBrightnessHigh( int boostBrightnessHigh ) + { + this.boostBrightnessHigh = boostBrightnessHigh; + } + + public void setEnhanceBrightness( boolean enhanceBrightness ) + { + this.enhanceBrightness = enhanceBrightness; + } } diff --git a/src/main/java/appeng/block/solids/OreQuartzCharged.java b/src/main/java/appeng/block/solids/OreQuartzCharged.java index e5054ff51..44a2ec6cf 100644 --- a/src/main/java/appeng/block/solids/OreQuartzCharged.java +++ b/src/main/java/appeng/block/solids/OreQuartzCharged.java @@ -19,15 +19,17 @@ package appeng.block.solids; import java.util.Random; +import javax.annotation.Nullable; import net.minecraft.client.Minecraft; -import net.minecraft.item.ItemStack; +import net.minecraft.item.Item; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import appeng.api.AEApi; +import appeng.api.exceptions.MissingDefinition; import appeng.client.render.effects.ChargedOreFX; import appeng.core.AEConfig; import appeng.core.CommonHelper; @@ -37,14 +39,20 @@ public class OreQuartzCharged extends OreQuartz public OreQuartzCharged() { super( OreQuartzCharged.class ); - this.boostBrightnessLow = 2; - this.boostBrightnessHigh = 5; + this.setBoostBrightnessLow( 2 ); + this.setBoostBrightnessHigh( 5 ); } + @Nullable @Override - ItemStack getItemDropped() + public Item getItemDropped( int id, Random rand, int meta ) { - return AEApi.instance().materials().materialCertusQuartzCrystalCharged.stack( 1 ); + for ( Item charged : AEApi.instance().definitions().materials().certusQuartzCrystalCharged().maybeItem().asSet() ) + { + return charged; + } + + throw new MissingDefinition( "Tried to access charged certus quartz crystal, even though they are disabled" ); } @Override diff --git a/src/main/java/appeng/block/stair/ChiseledQuartzStairBlock.java b/src/main/java/appeng/block/stair/ChiseledQuartzStairBlock.java index e8d622a1a..51dce1b92 100644 --- a/src/main/java/appeng/block/stair/ChiseledQuartzStairBlock.java +++ b/src/main/java/appeng/block/stair/ChiseledQuartzStairBlock.java @@ -21,15 +21,16 @@ package appeng.block.stair; import java.util.EnumSet; +import net.minecraft.block.Block; + import appeng.block.AEBaseStairBlock; -import appeng.block.solids.BlockQuartzChiseled; import appeng.core.features.AEFeature; public class ChiseledQuartzStairBlock extends AEBaseStairBlock { - public ChiseledQuartzStairBlock( BlockQuartzChiseled block ) + public ChiseledQuartzStairBlock( Block block ) { - super( block, 0, EnumSet.of( AEFeature.Core ) ); + super( block, 0, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) ); } } diff --git a/src/main/java/appeng/block/stair/FluixStairBlock.java b/src/main/java/appeng/block/stair/FluixStairBlock.java index 87a34f090..6d0d5083e 100644 --- a/src/main/java/appeng/block/stair/FluixStairBlock.java +++ b/src/main/java/appeng/block/stair/FluixStairBlock.java @@ -31,6 +31,6 @@ public class FluixStairBlock extends AEBaseStairBlock { public FluixStairBlock( Block block ) { - super( block, 0, EnumSet.of( AEFeature.Core ) ); + super( block, 0, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) ); } } diff --git a/src/main/java/appeng/block/stair/QuartzPillarStairBlock.java b/src/main/java/appeng/block/stair/QuartzPillarStairBlock.java index 1433a1c56..886229cf4 100644 --- a/src/main/java/appeng/block/stair/QuartzPillarStairBlock.java +++ b/src/main/java/appeng/block/stair/QuartzPillarStairBlock.java @@ -21,15 +21,16 @@ package appeng.block.stair; import java.util.EnumSet; +import net.minecraft.block.Block; + import appeng.block.AEBaseStairBlock; -import appeng.block.solids.BlockQuartzPillar; import appeng.core.features.AEFeature; public class QuartzPillarStairBlock extends AEBaseStairBlock { - public QuartzPillarStairBlock( BlockQuartzPillar block ) + public QuartzPillarStairBlock( Block block ) { - super( block, 0, EnumSet.of( AEFeature.Core ) ); + super( block, 0, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) ); } } diff --git a/src/main/java/appeng/block/stair/QuartzStairBlock.java b/src/main/java/appeng/block/stair/QuartzStairBlock.java index b91845839..32a3c287e 100644 --- a/src/main/java/appeng/block/stair/QuartzStairBlock.java +++ b/src/main/java/appeng/block/stair/QuartzStairBlock.java @@ -21,15 +21,16 @@ package appeng.block.stair; import java.util.EnumSet; +import net.minecraft.block.Block; + import appeng.block.AEBaseStairBlock; -import appeng.block.solids.BlockQuartz; import appeng.core.features.AEFeature; public class QuartzStairBlock extends AEBaseStairBlock { - public QuartzStairBlock( BlockQuartz block ) + public QuartzStairBlock( Block block ) { - super( block, 0, EnumSet.of( AEFeature.Core ) ); + super( block, 0, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) ); } } diff --git a/src/main/java/appeng/block/stair/SkyStoneBlockStairBlock.java b/src/main/java/appeng/block/stair/SkyStoneBlockStairBlock.java index 4eeb0aace..06d0009a2 100644 --- a/src/main/java/appeng/block/stair/SkyStoneBlockStairBlock.java +++ b/src/main/java/appeng/block/stair/SkyStoneBlockStairBlock.java @@ -31,6 +31,6 @@ public class SkyStoneBlockStairBlock extends AEBaseStairBlock { public SkyStoneBlockStairBlock( Block block, Integer meta ) { - super( block, meta, EnumSet.of( AEFeature.Core ) ); + super( block, meta, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) ); } } diff --git a/src/main/java/appeng/block/stair/SkyStoneBrickStairBlock.java b/src/main/java/appeng/block/stair/SkyStoneBrickStairBlock.java index 7b6881ed5..7e87da11d 100644 --- a/src/main/java/appeng/block/stair/SkyStoneBrickStairBlock.java +++ b/src/main/java/appeng/block/stair/SkyStoneBrickStairBlock.java @@ -31,6 +31,6 @@ public class SkyStoneBrickStairBlock extends AEBaseStairBlock { public SkyStoneBrickStairBlock( Block block, Integer meta ) { - super( block, meta, EnumSet.of( AEFeature.Core ) ); + super( block, meta, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) ); } } \ No newline at end of file diff --git a/src/main/java/appeng/block/stair/SkyStoneSmallBrickStairBlock.java b/src/main/java/appeng/block/stair/SkyStoneSmallBrickStairBlock.java index e5a0b1802..cb803188c 100644 --- a/src/main/java/appeng/block/stair/SkyStoneSmallBrickStairBlock.java +++ b/src/main/java/appeng/block/stair/SkyStoneSmallBrickStairBlock.java @@ -31,6 +31,6 @@ public class SkyStoneSmallBrickStairBlock extends AEBaseStairBlock { public SkyStoneSmallBrickStairBlock( Block block, int meta ) { - super( block, meta, EnumSet.of( AEFeature.Core ) ); + super( block, meta, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) ); } } \ No newline at end of file diff --git a/src/main/java/appeng/block/stair/SkyStoneStairBlock.java b/src/main/java/appeng/block/stair/SkyStoneStairBlock.java index 8d8b70e6b..a389019f5 100644 --- a/src/main/java/appeng/block/stair/SkyStoneStairBlock.java +++ b/src/main/java/appeng/block/stair/SkyStoneStairBlock.java @@ -31,6 +31,6 @@ public class SkyStoneStairBlock extends AEBaseStairBlock { public SkyStoneStairBlock( Block block, Integer meta ) { - super( block, meta, EnumSet.of( AEFeature.Core ) ); + super( block, meta, EnumSet.of( AEFeature.DecorativeQuartzBlocks ) ); } } diff --git a/src/main/java/appeng/block/storage/BlockSkyChest.java b/src/main/java/appeng/block/storage/BlockSkyChest.java index 57e0c5e4c..cc7e6c40d 100644 --- a/src/main/java/appeng/block/storage/BlockSkyChest.java +++ b/src/main/java/appeng/block/storage/BlockSkyChest.java @@ -23,11 +23,13 @@ import java.util.Collections; import java.util.EnumSet; import java.util.List; +import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; @@ -81,9 +83,12 @@ public class BlockSkyChest extends AEBaseBlock implements ICustomCollision @SideOnly(Side.CLIENT) public IIcon getIcon(int direction, int metadata) { - if ( metadata == 1 ) - return AEApi.instance().blocks().blockSkyStone.block().getIcon( direction, 1 ); - return AEApi.instance().blocks().blockSkyStone.block().getIcon( direction, metadata ); + for ( Block skyStoneBlock : AEApi.instance().definitions().blocks().skyStone().maybeBlock().asSet() ) + { + return skyStoneBlock.getIcon( direction, metadata ); + } + + return Blocks.stone.getIcon( direction, metadata ); } @Override diff --git a/src/main/java/appeng/client/ClientHelper.java b/src/main/java/appeng/client/ClientHelper.java index e179acbd9..5e74d126d 100644 --- a/src/main/java/appeng/client/ClientHelper.java +++ b/src/main/java/appeng/client/ClientHelper.java @@ -18,9 +18,6 @@ package appeng.client; -import static net.minecraftforge.client.IItemRenderer.ItemRenderType.ENTITY; -import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D; - import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -86,6 +83,9 @@ import appeng.server.ServerHelper; import appeng.transformer.MissingCoreMod; import appeng.util.Platform; +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.ENTITY; +import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D; + public class ClientHelper extends ServerHelper { @@ -290,7 +290,7 @@ public class ClientHelper extends ServerHelper public void bindTileEntitySpecialRenderer(Class tile, AEBaseBlock blk) { BaseBlockRender bbr = blk.getRendererInstance().rendererInstance; - if ( bbr.hasTESR && tile != null ) + if ( bbr.hasTESR() && tile != null ) ClientRegistry.bindTileEntitySpecialRenderer( tile, new TESRWrapper( bbr ) ); } diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java b/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java index 9ad2a71ca..0992914d5 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java @@ -23,6 +23,8 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import appeng.api.AEApi; +import appeng.api.definitions.IDefinitions; +import appeng.api.definitions.IParts; import appeng.api.storage.ITerminalHost; import appeng.client.gui.AEBaseGui; import appeng.client.gui.widgets.GuiNumberBox; @@ -35,6 +37,7 @@ import appeng.core.sync.GuiBridge; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketCraftRequest; import appeng.core.sync.packets.PacketSwitchGuis; +import appeng.helpers.Reflected; import appeng.helpers.WirelessTerminalGuiObject; import appeng.parts.reporting.PartCraftingTerminal; import appeng.parts.reporting.PartPatternTerminal; @@ -42,23 +45,23 @@ import appeng.parts.reporting.PartTerminal; public class GuiCraftAmount extends AEBaseGui { + private GuiNumberBox amountToCraft; + private GuiTabButton originalGuiBtn; - GuiNumberBox amountToCraft; - GuiTabButton originalGuiBtn; + private GuiButton next; - GuiButton next; + private GuiButton plus1; + private GuiButton plus10; + private GuiButton plus100; + private GuiButton plus1000; + private GuiButton minus1; + private GuiButton minus10; + private GuiButton minus100; + private GuiButton minus1000; - GuiButton plus1; - GuiButton plus10; - GuiButton plus100; - GuiButton plus1000; - GuiButton minus1; - GuiButton minus10; - GuiButton minus100; - GuiButton minus1000; - - GuiBridge OriginalGui; + private GuiBridge originalGui; + @Reflected public GuiCraftAmount(InventoryPlayer inventoryPlayer, ITerminalHost te) { super( new ContainerCraftAmount( inventoryPlayer, te ) ); } @@ -87,33 +90,50 @@ public class GuiCraftAmount extends AEBaseGui ItemStack myIcon = null; Object target = ((AEBaseContainer) this.inventorySlots).getTarget(); + final IDefinitions definitions = AEApi.instance().definitions(); + final IParts parts = definitions.parts(); if ( target instanceof WirelessTerminalGuiObject ) { - myIcon = AEApi.instance().items().itemWirelessTerminal.stack( 1 ); - this.OriginalGui = GuiBridge.GUI_WIRELESS_TERM; + for ( ItemStack wirelessTerminalStack : definitions.items().wirelessTerminal().maybeStack( 1 ).asSet() ) + { + myIcon = wirelessTerminalStack; + } + + this.originalGui = GuiBridge.GUI_WIRELESS_TERM; } if ( target instanceof PartTerminal ) { - myIcon = AEApi.instance().parts().partTerminal.stack( 1 ); - this.OriginalGui = GuiBridge.GUI_ME; + for ( ItemStack stack : parts.terminal().maybeStack( 1 ).asSet() ) + { + myIcon = stack; + } + this.originalGui = GuiBridge.GUI_ME; } if ( target instanceof PartCraftingTerminal ) { - myIcon = AEApi.instance().parts().partCraftingTerminal.stack( 1 ); - this.OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL; + for ( ItemStack stack : parts.craftingTerminal().maybeStack( 1 ).asSet() ) + { + myIcon = stack; + } + this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL; } if ( target instanceof PartPatternTerminal ) { - myIcon = AEApi.instance().parts().partPatternTerminal.stack( 1 ); - this.OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL; + for ( ItemStack stack : parts.patternTerminal().maybeStack( 1 ).asSet() ) + { + myIcon = stack; + } + this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL; } - if ( this.OriginalGui != null ) + if ( this.originalGui != null && myIcon != null ) + { this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) ); + } this.amountToCraft = new GuiNumberBox( this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Integer.class ); this.amountToCraft.setEnableBackgroundDrawing( false ); @@ -134,7 +154,7 @@ public class GuiCraftAmount extends AEBaseGui if ( btn == this.originalGuiBtn ) { - NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.OriginalGui ) ); + NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.originalGui ) ); } if ( btn == this.next ) @@ -160,22 +180,22 @@ public class GuiCraftAmount extends AEBaseGui { try { - String Out = this.amountToCraft.getText(); + String out = this.amountToCraft.getText(); - boolean Fixed = false; - while (Out.startsWith( "0" ) && Out.length() > 1) + boolean fixed = false; + while (out.startsWith( "0" ) && out.length() > 1) { - Out = Out.substring( 1 ); - Fixed = true; + out = out.substring( 1 ); + fixed = true; } - if ( Fixed ) - this.amountToCraft.setText( Out ); + if ( fixed ) + this.amountToCraft.setText( out ); - if ( Out.length() == 0 ) - Out = "0"; + if ( out.length() == 0 ) + out = "0"; - long result = Integer.parseInt( Out ); + long result = Integer.parseInt( out ); if ( result == 1 && i > 1 ) result = 0; @@ -184,9 +204,9 @@ public class GuiCraftAmount extends AEBaseGui if ( result < 1 ) result = 1; - Out = Long.toString( result ); - Integer.parseInt( Out ); - this.amountToCraft.setText( Out ); + out = Long.toString( result ); + Integer.parseInt( out ); + this.amountToCraft.setText( out ); } catch (NumberFormatException e) { @@ -208,22 +228,22 @@ public class GuiCraftAmount extends AEBaseGui { try { - String Out = this.amountToCraft.getText(); + String out = this.amountToCraft.getText(); - boolean Fixed = false; - while (Out.startsWith( "0" ) && Out.length() > 1) + boolean fixed = false; + while (out.startsWith( "0" ) && out.length() > 1) { - Out = Out.substring( 1 ); - Fixed = true; + out = out.substring( 1 ); + fixed = true; } - if ( Fixed ) - this.amountToCraft.setText( Out ); + if ( fixed ) + this.amountToCraft.setText( out ); - if ( Out.length() == 0 ) - Out = "0"; + if ( out.length() == 0 ) + out = "0"; - long result = Long.parseLong( Out ); + long result = Long.parseLong( out ); if ( result < 0 ) { this.amountToCraft.setText( "1" ); diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftConfirm.java b/src/main/java/appeng/client/gui/implementations/GuiCraftConfirm.java index a661628d7..2cda2c398 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftConfirm.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftConfirm.java @@ -128,7 +128,7 @@ public class GuiCraftConfirm extends AEBaseGui private void updateCPUButtonText() { String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal(); - if ( this.ccc.selectedCpu >= 0 )// && ccc.selectedCpu < ccc.cpus.size() ) + if ( this.ccc.selectedCpu >= 0 )// && status.selectedCpu < status.cpus.size() ) { if ( this.ccc.myName.length() > 0 ) { diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java b/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java index c0ffb8e73..4a90690c6 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java @@ -30,6 +30,8 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import appeng.api.AEApi; +import appeng.api.definitions.IDefinitions; +import appeng.api.definitions.IParts; import appeng.api.storage.ITerminalHost; import appeng.client.gui.widgets.GuiTabButton; import appeng.container.implementations.ContainerCraftingStatus; @@ -47,41 +49,56 @@ import appeng.parts.reporting.PartTerminal; public class GuiCraftingStatus extends GuiCraftingCPU { - final ContainerCraftingStatus ccc; + final ContainerCraftingStatus status; GuiButton selectCPU; GuiTabButton originalGuiBtn; - GuiBridge OriginalGui; + GuiBridge originalGui; ItemStack myIcon = null; public GuiCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) { super( new ContainerCraftingStatus( inventoryPlayer, te ) ); - this.ccc = (ContainerCraftingStatus) this.inventorySlots; - Object target = this.ccc.getTarget(); + this.status = (ContainerCraftingStatus) this.inventorySlots; + Object target = this.status.getTarget(); + final IDefinitions definitions = AEApi.instance().definitions(); + final IParts parts = definitions.parts(); if ( target instanceof WirelessTerminalGuiObject ) { - this.myIcon = AEApi.instance().items().itemWirelessTerminal.stack( 1 ); - this.OriginalGui = GuiBridge.GUI_WIRELESS_TERM; + for ( ItemStack wirelessTerminalStack : definitions.items().wirelessTerminal().maybeStack( 1 ).asSet() ) + { + this.myIcon = wirelessTerminalStack; + } + + this.originalGui = GuiBridge.GUI_WIRELESS_TERM; } if ( target instanceof PartTerminal ) { - this.myIcon = AEApi.instance().parts().partTerminal.stack( 1 ); - this.OriginalGui = GuiBridge.GUI_ME; + for ( ItemStack stack : parts.terminal().maybeStack( 1 ).asSet() ) + { + this.myIcon = stack; + } + this.originalGui = GuiBridge.GUI_ME; } if ( target instanceof PartCraftingTerminal ) { - this.myIcon = AEApi.instance().parts().partCraftingTerminal.stack( 1 ); - this.OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL; + for ( ItemStack stack : parts.craftingTerminal().maybeStack( 1 ).asSet() ) + { + this.myIcon = stack; + } + this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL; } if ( target instanceof PartPatternTerminal ) { - this.myIcon = AEApi.instance().parts().partPatternTerminal.stack( 1 ); - this.OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL; + for ( ItemStack stack : parts.patternTerminal().maybeStack( 1 ).asSet() ) + { + this.myIcon = stack; + } + this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL; } } @@ -106,7 +123,7 @@ public class GuiCraftingStatus extends GuiCraftingCPU if ( btn == this.originalGuiBtn ) { - NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.OriginalGui ) ); + NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.originalGui ) ); } } @@ -136,27 +153,27 @@ public class GuiCraftingStatus extends GuiCraftingCPU { String btnTextText = GuiText.NoCraftingJobs.getLocal(); - if ( this.ccc.selectedCpu >= 0 )// && ccc.selectedCpu < ccc.cpus.size() ) + if ( this.status.selectedCpu >= 0 )// && status.selectedCpu < status.cpus.size() ) { - if ( this.ccc.myName.length() > 0 ) + if ( this.status.myName.length() > 0 ) { - String name = this.ccc.myName.substring( 0, Math.min( 20, this.ccc.myName.length() ) ); + String name = this.status.myName.substring( 0, Math.min( 20, this.status.myName.length() ) ); btnTextText = GuiText.CPUs.getLocal() + ": " + name; } else - btnTextText = GuiText.CPUs.getLocal() + ": #" + this.ccc.selectedCpu; + btnTextText = GuiText.CPUs.getLocal() + ": #" + this.status.selectedCpu; } - if ( this.ccc.noCPU ) + if ( this.status.noCPU ) btnTextText = GuiText.NoCraftingJobs.getLocal(); this.selectCPU.displayString = btnTextText; } @Override - public void drawScreen(int mouse_x, int mouse_y, float btn) + public void drawScreen(int mouseX, int mouseY, float btn) { this.updateCPUButtonText(); - super.drawScreen( mouse_x, mouse_y, btn ); + super.drawScreen( mouseX, mouseY, btn ); } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiIOPort.java b/src/main/java/appeng/client/gui/implementations/GuiIOPort.java index 907493da6..acf6acab6 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiIOPort.java +++ b/src/main/java/appeng/client/gui/implementations/GuiIOPort.java @@ -22,12 +22,14 @@ import org.lwjgl.input.Mouse; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; import appeng.api.AEApi; import appeng.api.config.FullnessMode; import appeng.api.config.OperationMode; import appeng.api.config.RedstoneMode; import appeng.api.config.Settings; +import appeng.api.definitions.IDefinitions; import appeng.client.gui.widgets.GuiImgButton; import appeng.container.implementations.ContainerIOPort; import appeng.core.localization.GuiText; @@ -50,8 +52,18 @@ public class GuiIOPort extends GuiUpgradeable public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) { super.drawBG( offsetX, offsetY, mouseX, mouseY ); - this.drawItem( offsetX + 66 - 8, offsetY + 17, AEApi.instance().items().itemCell1k.stack( 1 ) ); - this.drawItem( offsetX + 94 + 8, offsetY + 17, AEApi.instance().blocks().blockDrive.stack( 1 ) ); + + final IDefinitions definitions = AEApi.instance().definitions(); + + for ( ItemStack cell1kStack : definitions.items().cell1k().maybeStack( 1 ).asSet() ) + { + this.drawItem( offsetX + 66 - 8, offsetY + 17, cell1kStack ); + } + + for ( ItemStack driveStack : definitions.blocks().drive().maybeStack( 1 ).asSet() ) + { + this.drawItem( offsetX + 94 + 8, offsetY + 17, driveStack ); + } } @Override diff --git a/src/main/java/appeng/client/gui/implementations/GuiPriority.java b/src/main/java/appeng/client/gui/implementations/GuiPriority.java index 95fd0dfad..ef12b62a6 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiPriority.java +++ b/src/main/java/appeng/client/gui/implementations/GuiPriority.java @@ -25,6 +25,9 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import appeng.api.AEApi; +import appeng.api.definitions.IBlocks; +import appeng.api.definitions.IDefinitions; +import appeng.api.definitions.IParts; import appeng.client.gui.AEBaseGui; import appeng.client.gui.widgets.GuiNumberBox; import appeng.client.gui.widgets.GuiTabButton; @@ -88,44 +91,68 @@ public class GuiPriority extends AEBaseGui ItemStack myIcon = null; Object target = ((AEBaseContainer) this.inventorySlots).getTarget(); + final IDefinitions definitions = AEApi.instance().definitions(); + final IParts parts = definitions.parts(); + final IBlocks blocks = definitions.blocks(); if ( target instanceof PartStorageBus ) { - myIcon = AEApi.instance().parts().partStorageBus.stack( 1 ); + for ( ItemStack storageBusStack :parts.storageBus().maybeStack( 1 ).asSet() ) + { + myIcon = storageBusStack; + } this.OriginalGui = GuiBridge.GUI_STORAGEBUS; } if ( target instanceof PartFormationPlane ) { - myIcon = AEApi.instance().parts().partFormationPlane.stack( 1 ); + for ( ItemStack formationPlaneStack : parts.formationPlane().maybeStack( 1 ).asSet() ) + { + myIcon = formationPlaneStack; + } this.OriginalGui = GuiBridge.GUI_FORMATION_PLANE; } if ( target instanceof TileDrive ) { - myIcon = AEApi.instance().blocks().blockDrive.stack( 1 ); + for ( ItemStack driveStack : blocks.drive().maybeStack( 1 ).asSet() ) + { + myIcon = driveStack; + } + this.OriginalGui = GuiBridge.GUI_DRIVE; } if ( target instanceof TileChest ) { - myIcon = AEApi.instance().blocks().blockChest.stack( 1 ); + for ( ItemStack chestStack : blocks.chest().maybeStack( 1 ).asSet() ) + { + myIcon = chestStack; + } + this.OriginalGui = GuiBridge.GUI_CHEST; } if ( target instanceof TileInterface ) { - myIcon = AEApi.instance().blocks().blockInterface.stack( 1 ); + for ( ItemStack interfaceStack : blocks.iface().maybeStack( 1 ).asSet() ) + { + myIcon = interfaceStack; + } + this.OriginalGui = GuiBridge.GUI_INTERFACE; } if ( target instanceof PartInterface ) { - myIcon = AEApi.instance().parts().partInterface.stack( 1 ); + for ( ItemStack interfaceStack : parts.iface().maybeStack( 1 ).asSet() ) + { + myIcon = interfaceStack; + } this.OriginalGui = GuiBridge.GUI_INTERFACE; } - if ( this.OriginalGui != null ) + if ( this.OriginalGui != null && myIcon != null ) this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) ); this.priority = new GuiNumberBox( this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Long.class ); @@ -158,27 +185,27 @@ public class GuiPriority extends AEBaseGui { try { - String Out = this.priority.getText(); + String out = this.priority.getText(); - boolean Fixed = false; - while (Out.startsWith( "0" ) && Out.length() > 1) + boolean fixed = false; + while (out.startsWith( "0" ) && out.length() > 1) { - Out = Out.substring( 1 ); - Fixed = true; + out = out.substring( 1 ); + fixed = true; } - if ( Fixed ) - this.priority.setText( Out ); + if ( fixed ) + this.priority.setText( out ); - if ( Out.length() == 0 ) - Out = "0"; + if ( out.length() == 0 ) + out = "0"; - long result = Long.parseLong( Out ); + long result = Long.parseLong( out ); result += i; - this.priority.setText( Out = Long.toString( result ) ); + this.priority.setText( out = Long.toString( result ) ); - NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", Out ) ); + NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) ); } catch(NumberFormatException e ) { @@ -201,22 +228,22 @@ public class GuiPriority extends AEBaseGui { try { - String Out = this.priority.getText(); + String out = this.priority.getText(); - boolean Fixed = false; - while (Out.startsWith( "0" ) && Out.length() > 1) + boolean fixed = false; + while (out.startsWith( "0" ) && out.length() > 1) { - Out = Out.substring( 1 ); - Fixed = true; + out = out.substring( 1 ); + fixed = true; } - if ( Fixed ) - this.priority.setText( Out ); + if ( fixed ) + this.priority.setText( out ); - if ( Out.length() == 0 ) - Out = "0"; + if ( out.length() == 0 ) + out = "0"; - NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", Out ) ); + NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) ); } catch (IOException e) { diff --git a/src/main/java/appeng/client/gui/widgets/GuiImgButton.java b/src/main/java/appeng/client/gui/widgets/GuiImgButton.java index 8e54064af..c9653a1d4 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiImgButton.java +++ b/src/main/java/appeng/client/gui/widgets/GuiImgButton.java @@ -85,10 +85,9 @@ public class GuiImgButton extends GuiButton implements ITooltip this.registerApp( 16 * 10, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits, PowerUnits.AE.unlocalizedName ); this.registerApp( 16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits, PowerUnits.EU.unlocalizedName ); - this.registerApp( 16 * 10 + 2, Settings.POWER_UNITS, PowerUnits.MJ, ButtonToolTips.PowerUnits, PowerUnits.MJ.unlocalizedName ); - this.registerApp( 16 * 10 + 3, Settings.POWER_UNITS, PowerUnits.MK, ButtonToolTips.PowerUnits, PowerUnits.MK.unlocalizedName ); - this.registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.WA, ButtonToolTips.PowerUnits, PowerUnits.WA.unlocalizedName ); - this.registerApp( 16 * 10 + 5, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.unlocalizedName ); + this.registerApp( 16 * 10 + 2, Settings.POWER_UNITS, PowerUnits.MK, ButtonToolTips.PowerUnits, PowerUnits.MK.unlocalizedName ); + this.registerApp( 16 * 10 + 3, Settings.POWER_UNITS, PowerUnits.WA, ButtonToolTips.PowerUnits, PowerUnits.WA.unlocalizedName ); + this.registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.unlocalizedName ); this.registerApp( 3, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, ButtonToolTips.RedstoneMode, ButtonToolTips.AlwaysActive ); this.registerApp( 0, Settings.REDSTONE_CONTROLLED, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithoutSignal ); diff --git a/src/main/java/appeng/client/render/BaseBlockRender.java b/src/main/java/appeng/client/render/BaseBlockRender.java index 8bd12ea64..20ecc331f 100644 --- a/src/main/java/appeng/client/render/BaseBlockRender.java +++ b/src/main/java/appeng/client/render/BaseBlockRender.java @@ -51,47 +51,29 @@ import appeng.client.texture.ExtraBlockTextures; import appeng.tile.AEBaseTile; import appeng.util.Platform; -@SideOnly(Side.CLIENT) + +@SideOnly( Side.CLIENT ) public class BaseBlockRender { - - final int ORIENTATION_BITS = 7; - final static int FLIP_H_BIT = 8; - final static int FLIP_V_BIT = 16; - - final double MAX_DISTANCE; - final public boolean hasTESR; + private static final int ORIENTATION_BITS = 7; + private static final int FLIP_H_BIT = 8; + private static final int FLIP_V_BIT = 16; private static final byte[][][] ORIENTATION_MAP = new byte[6][6][6]; - protected int adjustBrightness(int v, double d) + private final boolean hasTESR; + private final double renderDistance; + private final FloatBuffer rotMat = BufferUtils.createFloatBuffer( 16 ); + + public BaseBlockRender() { - int r = 0xff & (v >> 16); - int g = 0xff & (v >> 8); - int b = 0xff & ( v ); - - r *= d; - g *= d; - b *= d; - - r = Math.min( 255, Math.max( 0, r ) ); - g = Math.min( 255, Math.max( 0, g ) ); - b = Math.min( 255, Math.max( 0, b ) ); - - return (r << 16) | (g << 8) | b; + this( false, 20 ); } - static public int getOrientation(ForgeDirection in, ForgeDirection forward, ForgeDirection up) + public BaseBlockRender( boolean enableTESR, double tileEntitySpecialRendererRange ) { - if ( in == null || in == ForgeDirection.UNKNOWN // 1 - || forward == null || forward == ForgeDirection.UNKNOWN // 2 - || up == null || up == ForgeDirection.UNKNOWN ) - return 0; - - int a = in.ordinal(); - int b = forward.ordinal(); - int c = up.ordinal(); - - return ORIENTATION_MAP[a][b][c]; + this.hasTESR = enableTESR; + this.renderDistance = tileEntitySpecialRendererRange; + setOriMap(); } static public void setOriMap() @@ -271,30 +253,76 @@ public class BaseBlockRender ORIENTATION_MAP[5][2][4] = 1 | FLIP_H_BIT; } - public BaseBlockRender() { - this( false, 20 ); + public boolean hasTESR() + { + return this.hasTESR; } - public BaseBlockRender(boolean enableTESR, double tileEntitySpecialRendererRange) { - this.hasTESR = enableTESR; - this.MAX_DISTANCE = tileEntitySpecialRendererRange; - setOriMap(); + protected int adjustBrightness( int v, double d ) + { + int r = 0xff & ( v >> 16 ); + int g = 0xff & ( v >> 8 ); + int b = 0xff & ( v ); + + r *= d; + g *= d; + b *= d; + + r = Math.min( 255, Math.max( 0, r ) ); + g = Math.min( 255, Math.max( 0, g ) ); + b = Math.min( 255, Math.max( 0, b ) ); + + return ( r << 16 ) | ( g << 8 ) | b; } public double getTesrRenderDistance() { - return this.MAX_DISTANCE; + return this.renderDistance; } - public IIcon firstNotNull(IIcon... s) + public void renderInventory( AEBaseBlock block, ItemStack item, RenderBlocks renderer, ItemRenderType type, Object[] data ) { - for (IIcon o : s) - if ( o != null ) - return o; - return ExtraBlockTextures.getMissing(); + Tessellator tess = Tessellator.instance; + + BlockRenderInfo info = block.getRendererInstance(); + if ( info.isValid() ) + { + if ( block.hasSubtypes() ) + block.setRenderStateByMeta( item.getItemDamage() ); + + renderer.uvRotateBottom = info.getTexture( ForgeDirection.DOWN ).setFlip( getOrientation( ForgeDirection.DOWN, ForgeDirection.SOUTH, ForgeDirection.UP ) ); + renderer.uvRotateTop = info.getTexture( ForgeDirection.UP ).setFlip( getOrientation( ForgeDirection.UP, ForgeDirection.SOUTH, ForgeDirection.UP ) ); + + renderer.uvRotateEast = info.getTexture( ForgeDirection.EAST ).setFlip( getOrientation( ForgeDirection.EAST, ForgeDirection.SOUTH, ForgeDirection.UP ) ); + renderer.uvRotateWest = info.getTexture( ForgeDirection.WEST ).setFlip( getOrientation( ForgeDirection.WEST, ForgeDirection.SOUTH, ForgeDirection.UP ) ); + + renderer.uvRotateNorth = info.getTexture( ForgeDirection.NORTH ).setFlip( getOrientation( ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.UP ) ); + renderer.uvRotateSouth = info.getTexture( ForgeDirection.SOUTH ).setFlip( getOrientation( ForgeDirection.SOUTH, ForgeDirection.SOUTH, ForgeDirection.UP ) ); + } + + this.renderInvBlock( EnumSet.allOf( ForgeDirection.class ), block, item, tess, 0xffffff, renderer ); + + if ( block.hasSubtypes() ) + info.setTemporaryRenderIcon( null ); + + renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0; } - public void renderInvBlock(EnumSet sides, AEBaseBlock block, ItemStack item, Tessellator tess, int color, RenderBlocks renderer) + static public int getOrientation( ForgeDirection in, ForgeDirection forward, ForgeDirection up ) + { + if ( in == null || in == ForgeDirection.UNKNOWN // 1 + || forward == null || forward == ForgeDirection.UNKNOWN // 2 + || up == null || up == ForgeDirection.UNKNOWN ) + return 0; + + int a = in.ordinal(); + int b = forward.ordinal(); + int c = up.ordinal(); + + return ORIENTATION_MAP[a][b][c]; + } + + public void renderInvBlock( EnumSet sides, AEBaseBlock block, ItemStack item, Tessellator tess, int color, RenderBlocks renderer ) { if ( Platform.isDrawing( tess ) ) tess.draw(); @@ -308,13 +336,7 @@ public class BaseBlockRender tess.startDrawingQuads(); tess.setNormal( 0.0F, -1.0F, 0.0F ); tess.setColorOpaque_I( color ); - renderer.renderFaceYNeg( - block, - 0.0D, - 0.0D, - 0.0D, - this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.DOWN ), - block.getIcon( ForgeDirection.DOWN.ordinal(), meta ) ) ); + renderer.renderFaceYNeg( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.DOWN ), block.getIcon( ForgeDirection.DOWN.ordinal(), meta ) ) ); tess.draw(); } @@ -323,13 +345,7 @@ public class BaseBlockRender tess.startDrawingQuads(); tess.setNormal( 0.0F, 1.0F, 0.0F ); tess.setColorOpaque_I( color ); - renderer.renderFaceYPos( - block, - 0.0D, - 0.0D, - 0.0D, - this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.UP ), - block.getIcon( ForgeDirection.UP.ordinal(), meta ) ) ); + renderer.renderFaceYPos( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.UP ), block.getIcon( ForgeDirection.UP.ordinal(), meta ) ) ); tess.draw(); } @@ -338,13 +354,7 @@ public class BaseBlockRender tess.startDrawingQuads(); tess.setNormal( 0.0F, 0.0F, -1.0F ); tess.setColorOpaque_I( color ); - renderer.renderFaceZNeg( - block, - 0.0D, - 0.0D, - 0.0D, - this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.NORTH ), - block.getIcon( ForgeDirection.NORTH.ordinal(), meta ) ) ); + renderer.renderFaceZNeg( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.NORTH ), block.getIcon( ForgeDirection.NORTH.ordinal(), meta ) ) ); tess.draw(); } @@ -353,13 +363,7 @@ public class BaseBlockRender tess.startDrawingQuads(); tess.setNormal( 0.0F, 0.0F, 1.0F ); tess.setColorOpaque_I( color ); - renderer.renderFaceZPos( - block, - 0.0D, - 0.0D, - 0.0D, - this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.SOUTH ), - block.getIcon( ForgeDirection.SOUTH.ordinal(), meta ) ) ); + renderer.renderFaceZPos( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.SOUTH ), block.getIcon( ForgeDirection.SOUTH.ordinal(), meta ) ) ); tess.draw(); } @@ -368,13 +372,7 @@ public class BaseBlockRender tess.startDrawingQuads(); tess.setNormal( -1.0F, 0.0F, 0.0F ); tess.setColorOpaque_I( color ); - renderer.renderFaceXNeg( - block, - 0.0D, - 0.0D, - 0.0D, - this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.WEST ), - block.getIcon( ForgeDirection.WEST.ordinal(), meta ) ) ); + renderer.renderFaceXNeg( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.WEST ), block.getIcon( ForgeDirection.WEST.ordinal(), meta ) ) ); tess.draw(); } @@ -383,60 +381,30 @@ public class BaseBlockRender tess.startDrawingQuads(); tess.setNormal( 1.0F, 0.0F, 0.0F ); tess.setColorOpaque_I( color ); - renderer.renderFaceXPos( - block, - 0.0D, - 0.0D, - 0.0D, - this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.EAST ), - block.getIcon( ForgeDirection.EAST.ordinal(), meta ) ) ); + renderer.renderFaceXPos( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.EAST ), block.getIcon( ForgeDirection.EAST.ordinal(), meta ) ) ); tess.draw(); } } - public void renderInventory(AEBaseBlock block, ItemStack item, RenderBlocks renderer, ItemRenderType type, Object[] data) + public IIcon firstNotNull( IIcon... s ) { - Tessellator tess = Tessellator.instance; - - BlockRenderInfo info = block.getRendererInstance(); - if ( info.isValid() ) - { - if ( block.hasSubtypes() ) - block.setRenderStateByMeta( item.getItemDamage() ); - - renderer.uvRotateBottom = info.getTexture( ForgeDirection.DOWN ).setFlip( - getOrientation( ForgeDirection.DOWN, ForgeDirection.SOUTH, ForgeDirection.UP ) ); - renderer.uvRotateTop = info.getTexture( ForgeDirection.UP ).setFlip( getOrientation( ForgeDirection.UP, ForgeDirection.SOUTH, ForgeDirection.UP ) ); - - renderer.uvRotateEast = info.getTexture( ForgeDirection.EAST ).setFlip( - getOrientation( ForgeDirection.EAST, ForgeDirection.SOUTH, ForgeDirection.UP ) ); - renderer.uvRotateWest = info.getTexture( ForgeDirection.WEST ).setFlip( - getOrientation( ForgeDirection.WEST, ForgeDirection.SOUTH, ForgeDirection.UP ) ); - - renderer.uvRotateNorth = info.getTexture( ForgeDirection.NORTH ).setFlip( - getOrientation( ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.UP ) ); - renderer.uvRotateSouth = info.getTexture( ForgeDirection.SOUTH ).setFlip( - getOrientation( ForgeDirection.SOUTH, ForgeDirection.SOUTH, ForgeDirection.UP ) ); - } - - this.renderInvBlock( EnumSet.allOf( ForgeDirection.class ), block, item, tess, 0xffffff, renderer ); - - if ( block.hasSubtypes() ) - info.setTemporaryRenderIcon( null ); - - renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0; + for ( IIcon o : s ) + if ( o != null ) + return o; + return ExtraBlockTextures.getMissing(); } - public IOrientable getOrientable(AEBaseBlock block, IBlockAccess w, int x, int y, int z) + public boolean renderInWorld( AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer ) { - if ( block.hasBlockTileEntity() ) - return (AEBaseTile) block.getTileEntity( w, x, y, z ); - else if ( block instanceof IOrientableBlock ) - return ((IOrientableBlock) block).getOrientable( w, x, y, z ); - return null; + this.preRenderInWorld( block, world, x, y, z, renderer ); + + boolean o = renderer.renderStandardBlock( block, x, y, z ); + + this.postRenderInWorld( renderer ); + return o; } - public void preRenderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer) + public void preRenderInWorld( AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer ) { ForgeDirection forward = ForgeDirection.SOUTH; ForgeDirection up = ForgeDirection.UP; @@ -457,80 +425,34 @@ public class BaseBlockRender renderer.uvRotateNorth = info.getTexture( ForgeDirection.NORTH ).setFlip( getOrientation( ForgeDirection.NORTH, forward, up ) ); renderer.uvRotateSouth = info.getTexture( ForgeDirection.SOUTH ).setFlip( getOrientation( ForgeDirection.SOUTH, forward, up ) ); } - } - public void postRenderInWorld(RenderBlocks renderer) + public void postRenderInWorld( RenderBlocks renderer ) { renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0; } - public boolean renderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer) + public IOrientable getOrientable( AEBaseBlock block, IBlockAccess w, int x, int y, int z ) { - this.preRenderInWorld( block, world, x, y, z, renderer ); - - boolean o = renderer.renderStandardBlock( block, x, y, z ); - - this.postRenderInWorld( renderer ); - return o; + if ( block.hasBlockTileEntity() ) + return (AEBaseTile) block.getTileEntity( w, x, y, z ); + else if ( block instanceof IOrientableBlock ) + return ( (IOrientableBlock) block ).getOrientable( w, x, y, z ); + return null; } - final FloatBuffer rotMat = BufferUtils.createFloatBuffer( 16 ); - - protected void applyTESRRotation(double x, double y, double z, ForgeDirection forward, ForgeDirection up) - { - if ( forward != null && up != null ) - { - if ( forward == ForgeDirection.UNKNOWN ) - forward = ForgeDirection.SOUTH; - - if ( up == ForgeDirection.UNKNOWN ) - up = ForgeDirection.UP; - - ForgeDirection west = Platform.crossProduct( forward, up ); - - this.rotMat.put( 0, west.offsetX ); - this.rotMat.put( 1, west.offsetY ); - this.rotMat.put( 2, west.offsetZ ); - this.rotMat.put( 3, 0 ); - - this.rotMat.put( 4, up.offsetX ); - this.rotMat.put( 5, up.offsetY ); - this.rotMat.put( 6, up.offsetZ ); - this.rotMat.put( 7, 0 ); - - this.rotMat.put( 8, forward.offsetX ); - this.rotMat.put( 9, forward.offsetY ); - this.rotMat.put( 10, forward.offsetZ ); - this.rotMat.put( 11, 0 ); - - this.rotMat.put( 12, 0 ); - this.rotMat.put( 13, 0 ); - this.rotMat.put( 14, 0 ); - this.rotMat.put( 15, 1 ); - GL11.glTranslated( x + 0.5, y + 0.5, z + 0.5 ); - GL11.glMultMatrix( this.rotMat ); - GL11.glTranslated( -0.5, -0.5, -0.5 ); - GL11.glCullFace( GL11.GL_FRONT ); - } - else - { - GL11.glTranslated( x, y, z ); - } - } - - protected void setInvRenderBounds(RenderBlocks renderer, int i, int j, int k, int l, int m, int n) + protected void setInvRenderBounds( RenderBlocks renderer, int i, int j, int k, int l, int m, int n ) { renderer.setRenderBounds( i / 16.0, j / 16.0, k / 16.0, l / 16.0, m / 16.0, n / 16.0 ); } - protected void renderBlockBounds(RenderBlocks renderer, + protected void renderBlockBounds( RenderBlocks renderer, - double minX, double minY, double minZ, + double minX, double minY, double minZ, - double maxX, double maxY, double maxZ, + double maxX, double maxY, double maxZ, - ForgeDirection x, ForgeDirection y, ForgeDirection z) + ForgeDirection x, ForgeDirection y, ForgeDirection z ) { minX /= 16.0; minY /= 16.0; @@ -573,36 +495,8 @@ public class BaseBlockRender renderer.renderMaxZ = Math.max( aZ, bZ ); } - @SideOnly(Side.CLIENT) - private void renderFace(Tessellator tess, double offsetX, double offsetY, double offsetZ, double ax, double ay, double az, double bx, double by, double bz, - double ua, double ub, double va, double vb, IIcon ico, boolean flip) - { - if ( flip ) - { - tess.addVertexWithUV( offsetX + ax * ua + bx * va, offsetY + ay * ua + by * va, offsetZ + az * ua + bz * va, ico.getInterpolatedU( ua * 16.0 ), - ico.getInterpolatedV( va * 16.0 ) ); - tess.addVertexWithUV( offsetX + ax * ua + bx * vb, offsetY + ay * ua + by * vb, offsetZ + az * ua + bz * vb, ico.getInterpolatedU( ua * 16.0 ), - ico.getInterpolatedV( vb * 16.0 ) ); - tess.addVertexWithUV( offsetX + ax * ub + bx * vb, offsetY + ay * ub + by * vb, offsetZ + az * ub + bz * vb, ico.getInterpolatedU( ub * 16.0 ), - ico.getInterpolatedV( vb * 16.0 ) ); - tess.addVertexWithUV( offsetX + ax * ub + bx * va, offsetY + ay * ub + by * va, offsetZ + az * ub + bz * va, ico.getInterpolatedU( ub * 16.0 ), - ico.getInterpolatedV( va * 16.0 ) ); - } - else - { - tess.addVertexWithUV( offsetX + ax * ua + bx * va, offsetY + ay * ua + by * va, offsetZ + az * ua + bz * va, ico.getInterpolatedU( ua * 16.0 ), - ico.getInterpolatedV( va * 16.0 ) ); - tess.addVertexWithUV( offsetX + ax * ub + bx * va, offsetY + ay * ub + by * va, offsetZ + az * ub + bz * va, ico.getInterpolatedU( ub * 16.0 ), - ico.getInterpolatedV( va * 16.0 ) ); - tess.addVertexWithUV( offsetX + ax * ub + bx * vb, offsetY + ay * ub + by * vb, offsetZ + az * ub + bz * vb, ico.getInterpolatedU( ub * 16.0 ), - ico.getInterpolatedV( vb * 16.0 ) ); - tess.addVertexWithUV( offsetX + ax * ua + bx * vb, offsetY + ay * ua + by * vb, offsetZ + az * ua + bz * vb, ico.getInterpolatedU( ua * 16.0 ), - ico.getInterpolatedV( vb * 16.0 ) ); - } - } - - @SideOnly(Side.CLIENT) - protected void renderCutoutFace(Block block, IIcon ico, int x, int y, int z, RenderBlocks renderer, ForgeDirection orientation, float edgeThickness) + @SideOnly( Side.CLIENT ) + protected void renderCutoutFace( Block block, IIcon ico, int x, int y, int z, RenderBlocks renderer, ForgeDirection orientation, float edgeThickness ) { Tessellator tess = Tessellator.instance; @@ -617,52 +511,52 @@ public class BaseBlockRender double layerBZ = 0.0; boolean flip = false; - switch (orientation) + switch ( orientation ) { - case NORTH: + case NORTH: - layerAX = 1.0; - layerBY = 1.0; - flip = true; + layerAX = 1.0; + layerBY = 1.0; + flip = true; - break; - case SOUTH: + break; + case SOUTH: - layerAX = 1.0; - layerBY = 1.0; - offsetZ = 1.0; + layerAX = 1.0; + layerBY = 1.0; + offsetZ = 1.0; - break; - case EAST: + break; + case EAST: - flip = true; - layerAZ = 1.0; - layerBY = 1.0; - offsetX = 1.0; + flip = true; + layerAZ = 1.0; + layerBY = 1.0; + offsetX = 1.0; - break; - case WEST: + break; + case WEST: - layerAZ = 1.0; - layerBY = 1.0; + layerAZ = 1.0; + layerBY = 1.0; - break; - case UP: + break; + case UP: - flip = true; - layerAX = 1.0; - layerBZ = 1.0; - offsetY = 1.0; + flip = true; + layerAX = 1.0; + layerBZ = 1.0; + offsetY = 1.0; - break; - case DOWN: + break; + case DOWN: - layerAX = 1.0; - layerBZ = 1.0; + layerAX = 1.0; + layerBZ = 1.0; - break; - default: - break; + break; + default: + break; } offsetX += x; @@ -670,82 +564,101 @@ public class BaseBlockRender offsetZ += z; this.renderFace( tess, offsetX, offsetY, offsetZ, layerAX, layerAY, layerAZ, layerBX, layerBY, layerBZ, - // u -> u + // u -> u 0, 1.0, // v -> v 0, edgeThickness, ico, flip ); this.renderFace( tess, offsetX, offsetY, offsetZ, layerAX, layerAY, layerAZ, layerBX, layerBY, layerBZ, - // u -> u + // u -> u 0.0, edgeThickness, // v -> v edgeThickness, 1.0 - edgeThickness, ico, flip ); this.renderFace( tess, offsetX, offsetY, offsetZ, layerAX, layerAY, layerAZ, layerBX, layerBY, layerBZ, - // u -> u + // u -> u 1.0 - edgeThickness, 1.0, // v -> v edgeThickness, 1.0 - edgeThickness, ico, flip ); this.renderFace( tess, offsetX, offsetY, offsetZ, layerAX, layerAY, layerAZ, layerBX, layerBY, layerBZ, - // u -> u + // u -> u 0, 1.0, // v -> v 1.0 - edgeThickness, 1.0, ico, flip ); } - @SideOnly(Side.CLIENT) - protected void renderFace(int x, int y, int z, Block block, IIcon ico, RenderBlocks renderer, ForgeDirection orientation) + @SideOnly( Side.CLIENT ) + private void renderFace( Tessellator tess, double offsetX, double offsetY, double offsetZ, double ax, double ay, double az, double bx, double by, double bz, double ua, double ub, double va, double vb, IIcon ico, boolean flip ) { - switch (orientation) + if ( flip ) { - case NORTH: - renderer.renderFaceZNeg( block, x, y, z, ico ); - break; - case SOUTH: - renderer.renderFaceZPos( block, x, y, z, ico ); - break; - case EAST: - renderer.renderFaceXPos( block, x, y, z, ico ); - break; - case WEST: - renderer.renderFaceXNeg( block, x, y, z, ico ); - break; - case UP: - renderer.renderFaceYPos( block, x, y, z, ico ); - break; - case DOWN: - renderer.renderFaceYNeg( block, x, y, z, ico ); - break; - default: - break; + tess.addVertexWithUV( offsetX + ax * ua + bx * va, offsetY + ay * ua + by * va, offsetZ + az * ua + bz * va, ico.getInterpolatedU( ua * 16.0 ), ico.getInterpolatedV( va * 16.0 ) ); + tess.addVertexWithUV( offsetX + ax * ua + bx * vb, offsetY + ay * ua + by * vb, offsetZ + az * ua + bz * vb, ico.getInterpolatedU( ua * 16.0 ), ico.getInterpolatedV( vb * 16.0 ) ); + tess.addVertexWithUV( offsetX + ax * ub + bx * vb, offsetY + ay * ub + by * vb, offsetZ + az * ub + bz * vb, ico.getInterpolatedU( ub * 16.0 ), ico.getInterpolatedV( vb * 16.0 ) ); + tess.addVertexWithUV( offsetX + ax * ub + bx * va, offsetY + ay * ub + by * va, offsetZ + az * ub + bz * va, ico.getInterpolatedU( ub * 16.0 ), ico.getInterpolatedV( va * 16.0 ) ); + } + else + { + tess.addVertexWithUV( offsetX + ax * ua + bx * va, offsetY + ay * ua + by * va, offsetZ + az * ua + bz * va, ico.getInterpolatedU( ua * 16.0 ), ico.getInterpolatedV( va * 16.0 ) ); + tess.addVertexWithUV( offsetX + ax * ub + bx * va, offsetY + ay * ub + by * va, offsetZ + az * ub + bz * va, ico.getInterpolatedU( ub * 16.0 ), ico.getInterpolatedV( va * 16.0 ) ); + tess.addVertexWithUV( offsetX + ax * ub + bx * vb, offsetY + ay * ub + by * vb, offsetZ + az * ub + bz * vb, ico.getInterpolatedU( ub * 16.0 ), ico.getInterpolatedV( vb * 16.0 ) ); + tess.addVertexWithUV( offsetX + ax * ua + bx * vb, offsetY + ay * ua + by * vb, offsetZ + az * ua + bz * vb, ico.getInterpolatedU( ua * 16.0 ), ico.getInterpolatedV( vb * 16.0 ) ); } } - public void selectFace(RenderBlocks renderer, ForgeDirection west, ForgeDirection up, ForgeDirection forward, int u1, int u2, int v1, int v2) + @SideOnly( Side.CLIENT ) + protected void renderFace( int x, int y, int z, Block block, IIcon ico, RenderBlocks renderer, ForgeDirection orientation ) + { + switch ( orientation ) + { + case NORTH: + renderer.renderFaceZNeg( block, x, y, z, ico ); + break; + case SOUTH: + renderer.renderFaceZPos( block, x, y, z, ico ); + break; + case EAST: + renderer.renderFaceXPos( block, x, y, z, ico ); + break; + case WEST: + renderer.renderFaceXNeg( block, x, y, z, ico ); + break; + case UP: + renderer.renderFaceYPos( block, x, y, z, ico ); + break; + case DOWN: + renderer.renderFaceYNeg( block, x, y, z, ico ); + break; + default: + break; + } + } + + public void selectFace( RenderBlocks renderer, ForgeDirection west, ForgeDirection up, ForgeDirection forward, int u1, int u2, int v1, int v2 ) { v1 = 16 - v1; v2 = 16 - v2; - double minX = (forward.offsetX > 0 ? 1 : 0) + this.mapFaceUV( west.offsetX, u1 ) + this.mapFaceUV( up.offsetX, v1 ); - double minY = (forward.offsetY > 0 ? 1 : 0) + this.mapFaceUV( west.offsetY, u1 ) + this.mapFaceUV( up.offsetY, v1 ); - double minZ = (forward.offsetZ > 0 ? 1 : 0) + this.mapFaceUV( west.offsetZ, u1 ) + this.mapFaceUV( up.offsetZ, v1 ); + double minX = ( forward.offsetX > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetX, u1 ) + this.mapFaceUV( up.offsetX, v1 ); + double minY = ( forward.offsetY > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetY, u1 ) + this.mapFaceUV( up.offsetY, v1 ); + double minZ = ( forward.offsetZ > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetZ, u1 ) + this.mapFaceUV( up.offsetZ, v1 ); - double maxX = (forward.offsetX > 0 ? 1 : 0) + this.mapFaceUV( west.offsetX, u2 ) + this.mapFaceUV( up.offsetX, v2 ); - double maxY = (forward.offsetY > 0 ? 1 : 0) + this.mapFaceUV( west.offsetY, u2 ) + this.mapFaceUV( up.offsetY, v2 ); - double maxZ = (forward.offsetZ > 0 ? 1 : 0) + this.mapFaceUV( west.offsetZ, u2 ) + this.mapFaceUV( up.offsetZ, v2 ); + double maxX = ( forward.offsetX > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetX, u2 ) + this.mapFaceUV( up.offsetX, v2 ); + double maxY = ( forward.offsetY > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetY, u2 ) + this.mapFaceUV( up.offsetY, v2 ); + double maxZ = ( forward.offsetZ > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetZ, u2 ) + this.mapFaceUV( up.offsetZ, v2 ); - renderer.renderMinX = Math.max( 0.0, Math.min( minX, maxX ) - (forward.offsetX != 0 ? 0 : 0.001) ); - renderer.renderMaxX = Math.min( 1.0, Math.max( minX, maxX ) + (forward.offsetX != 0 ? 0 : 0.001) ); + renderer.renderMinX = Math.max( 0.0, Math.min( minX, maxX ) - ( forward.offsetX != 0 ? 0 : 0.001 ) ); + renderer.renderMaxX = Math.min( 1.0, Math.max( minX, maxX ) + ( forward.offsetX != 0 ? 0 : 0.001 ) ); - renderer.renderMinY = Math.max( 0.0, Math.min( minY, maxY ) - (forward.offsetY != 0 ? 0 : 0.001) ); - renderer.renderMaxY = Math.min( 1.0, Math.max( minY, maxY ) + (forward.offsetY != 0 ? 0 : 0.001) ); + renderer.renderMinY = Math.max( 0.0, Math.min( minY, maxY ) - ( forward.offsetY != 0 ? 0 : 0.001 ) ); + renderer.renderMaxY = Math.min( 1.0, Math.max( minY, maxY ) + ( forward.offsetY != 0 ? 0 : 0.001 ) ); - renderer.renderMinZ = Math.max( 0.0, Math.min( minZ, maxZ ) - (forward.offsetZ != 0 ? 0 : 0.001) ); - renderer.renderMaxZ = Math.min( 1.0, Math.max( minZ, maxZ ) + (forward.offsetZ != 0 ? 0 : 0.001) ); + renderer.renderMinZ = Math.max( 0.0, Math.min( minZ, maxZ ) - ( forward.offsetZ != 0 ? 0 : 0.001 ) ); + renderer.renderMaxZ = Math.min( 1.0, Math.max( minZ, maxZ ) + ( forward.offsetZ != 0 ? 0 : 0.001 ) ); } - private double mapFaceUV(int offset, int uv) + private double mapFaceUV( int offset, int uv ) { if ( offset == 0 ) return 0; @@ -753,10 +666,10 @@ public class BaseBlockRender if ( offset > 0 ) return uv / 16.0; - return (16.0 - uv) / 16.0; + return ( 16.0 - uv ) / 16.0; } - public void renderTile(AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float f, RenderBlocks renderer) + public void renderTile( AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float f, RenderBlocks renderer ) { ForgeDirection forward = ForgeDirection.SOUTH; ForgeDirection up = ForgeDirection.UP; @@ -789,7 +702,49 @@ public class BaseBlockRender renderer.uvRotateBottom = renderer.uvRotateTop = renderer.uvRotateEast = renderer.uvRotateWest = renderer.uvRotateNorth = renderer.uvRotateSouth = 0; } - public void doRenderItem(ItemStack itemstack, TileEntity par1EntityItemFrame) + protected void applyTESRRotation( double x, double y, double z, ForgeDirection forward, ForgeDirection up ) + { + if ( forward != null && up != null ) + { + if ( forward == ForgeDirection.UNKNOWN ) + forward = ForgeDirection.SOUTH; + + if ( up == ForgeDirection.UNKNOWN ) + up = ForgeDirection.UP; + + ForgeDirection west = Platform.crossProduct( forward, up ); + + this.rotMat.put( 0, west.offsetX ); + this.rotMat.put( 1, west.offsetY ); + this.rotMat.put( 2, west.offsetZ ); + this.rotMat.put( 3, 0 ); + + this.rotMat.put( 4, up.offsetX ); + this.rotMat.put( 5, up.offsetY ); + this.rotMat.put( 6, up.offsetZ ); + this.rotMat.put( 7, 0 ); + + this.rotMat.put( 8, forward.offsetX ); + this.rotMat.put( 9, forward.offsetY ); + this.rotMat.put( 10, forward.offsetZ ); + this.rotMat.put( 11, 0 ); + + this.rotMat.put( 12, 0 ); + this.rotMat.put( 13, 0 ); + this.rotMat.put( 14, 0 ); + this.rotMat.put( 15, 1 ); + GL11.glTranslated( x + 0.5, y + 0.5, z + 0.5 ); + GL11.glMultMatrix( this.rotMat ); + GL11.glTranslated( -0.5, -0.5, -0.5 ); + GL11.glCullFace( GL11.GL_FRONT ); + } + else + { + GL11.glTranslated( x, y, z ); + } + } + + public void doRenderItem( ItemStack itemstack, TileEntity par1EntityItemFrame ) { if ( itemstack != null ) { @@ -811,5 +766,4 @@ public class BaseBlockRender GL11.glPopMatrix(); } } - } diff --git a/src/main/java/appeng/client/render/BusRenderHelper.java b/src/main/java/appeng/client/render/BusRenderHelper.java index 8f410b932..f787d947a 100644 --- a/src/main/java/appeng/client/render/BusRenderHelper.java +++ b/src/main/java/appeng/client/render/BusRenderHelper.java @@ -18,7 +18,9 @@ package appeng.client.render; + import java.util.EnumSet; +import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; @@ -29,7 +31,11 @@ import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import com.google.common.base.Function; +import com.google.common.base.Optional; + import appeng.api.AEApi; +import appeng.api.exceptions.MissingDefinition; import appeng.api.parts.IBoxProvider; import appeng.api.parts.IPartCollisionHelper; import appeng.api.parts.IPartRenderHelper; @@ -39,43 +45,143 @@ import appeng.block.networking.BlockCableBus; import appeng.core.AEConfig; import appeng.core.features.AEFeature; -@SideOnly(Side.CLIENT) -public class BusRenderHelper implements IPartRenderHelper + +@SideOnly( Side.CLIENT ) +public final class BusRenderHelper implements IPartRenderHelper { + public static final BusRenderHelper INSTANCE = new BusRenderHelper(); + private static final int HEX_WHITE = 0xffffff; - final public static BusRenderHelper INSTANCE = new BusRenderHelper(); + private final BoundBoxCalculator bbc; + private final boolean noAlphaPass; + private final BaseBlockRender bbr; + private final Optional maybeBlock; + private final Optional maybeBaseBlock; + private int renderingForPass; + private int currentPass; + private int itemsRendered; + private double minX; + private double minY; + private double minZ; + private double maxX; + private double maxY; + private double maxZ; + private ForgeDirection ax; + private ForgeDirection ay; + private ForgeDirection az; + private int color; - double minX = 0; - double minY = 0; - double minZ = 0; - double maxX = 16; - double maxY = 16; - double maxZ = 16; - - final AEBaseBlock blk = (AEBaseBlock) AEApi.instance().blocks().blockMultiPart.block(); - final BaseBlockRender bbr = new BaseBlockRender(); - - private ForgeDirection ax = ForgeDirection.EAST; - private ForgeDirection ay = ForgeDirection.UP; - private ForgeDirection az = ForgeDirection.SOUTH; - - int color = 0xffffff; - - class BoundBoxCalculator implements IPartCollisionHelper + public BusRenderHelper() { + this.bbc = new BoundBoxCalculator( this ); + this.noAlphaPass = !AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ); + this.bbr = new BaseBlockRender(); + this.renderingForPass = 0; + this.currentPass = 0; + this.itemsRendered = 0; + this.minX = 0; + this.minY = 0; + this.minZ = 0; + this.maxX = 16; + this.maxY = 16; + this.maxZ = 16; + this.ax = ForgeDirection.EAST; + this.az = ForgeDirection.SOUTH; + this.ay = ForgeDirection.UP; + this.color = HEX_WHITE; + this.maybeBlock = AEApi.instance().definitions().blocks().multiPart().maybeBlock(); + this.maybeBaseBlock = this.maybeBlock.transform( new BaseBlockTransformFunction() ); + } - public boolean started = false; + public int getItemsRendered() + { + return this.itemsRendered; + } - float minX; - float minY; - float minZ; + public void setPass( int pass ) + { + this.renderingForPass = 0; + this.currentPass = pass; + this.itemsRendered = 0; + } - float maxX; - float maxY; - float maxZ; + public double getBound( ForgeDirection side ) + { + switch ( side ) + { + default: + case UNKNOWN: + return 0.5; + case DOWN: + return this.minY; + case EAST: + return this.maxX; + case NORTH: + return this.minZ; + case SOUTH: + return this.maxZ; + case UP: + return this.maxY; + case WEST: + return this.minX; + } + } + + public void setRenderColor( int color ) + { + for ( Block block : AEApi.instance().definitions().blocks().multiPart().maybeBlock().asSet() ) + { + final BlockCableBus cableBus = (BlockCableBus) block; + cableBus.setRenderColor( color ); + } + } + + public void setOrientation( ForgeDirection dx, ForgeDirection dy, ForgeDirection dz ) + { + this.ax = dx == null ? ForgeDirection.EAST : dx; + this.ay = dy == null ? ForgeDirection.UP : dy; + this.az = dz == null ? ForgeDirection.SOUTH : dz; + } + + public double[] getBounds() + { + return new double[] { this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ }; + } + + public void setBounds( double[] bounds ) + { + if ( bounds == null || bounds.length != 6 ) + return; + + this.minX = bounds[0]; + this.minY = bounds[1]; + this.minZ = bounds[2]; + this.maxX = bounds[3]; + this.maxY = bounds[4]; + this.maxZ = bounds[5]; + } + + + private static class BoundBoxCalculator implements IPartCollisionHelper + { + private final BusRenderHelper helper; + private boolean started = false; + + private float minX; + private float minY; + private float minZ; + + private float maxX; + private float maxY; + private float maxZ; + + public BoundBoxCalculator( BusRenderHelper helper ) + { + this.helper = helper; + } @Override - public void addBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) + public void addBox( double minX, double minY, double minZ, double maxX, double maxY, double maxZ ) { if ( this.started ) { @@ -101,19 +207,19 @@ public class BusRenderHelper implements IPartRenderHelper @Override public ForgeDirection getWorldX() { - return BusRenderHelper.this.ax; + return this.helper.ax; } @Override public ForgeDirection getWorldY() { - return BusRenderHelper.this.ay; + return this.helper.ay; } @Override public ForgeDirection getWorldZ() { - return BusRenderHelper.this.az; + return this.helper.az; } @Override @@ -121,34 +227,14 @@ public class BusRenderHelper implements IPartRenderHelper { return false; } - - } - - final BoundBoxCalculator bbc = new BoundBoxCalculator(); - - int renderingForPass = 0; - int currentPass = 0; - int itemsRendered = 0; - final boolean noAlphaPass = !AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ); - - public int getItemsRendered() - { - return this.itemsRendered; - } - - public void setPass(int pass) - { - this.renderingForPass = 0; - this.currentPass = pass; - this.itemsRendered = 0; - } - - @Override - public void renderForPass(int pass) + } @Override + public void renderForPass( int pass ) { this.renderingForPass = pass; } + + public boolean renderThis() { if ( this.renderingForPass == this.currentPass || this.noAlphaPass ) @@ -169,11 +255,11 @@ public class BusRenderHelper implements IPartRenderHelper } @Override - public ISimplifiedBundle useSimplifiedRendering(int x, int y, int z, IBoxProvider p, ISimplifiedBundle sim) + public ISimplifiedBundle useSimplifiedRendering( int x, int y, int z, IBoxProvider p, ISimplifiedBundle sim ) { RenderBlocksWorkaround rbw = BusRenderer.INSTANCE.renderer; - if ( sim != null && rbw.similarLighting( this.blk, rbw.blockAccess, x, y, z, sim ) ) + if ( sim != null && this.maybeBlock.isPresent() && rbw.similarLighting( this.maybeBlock.get(), rbw.blockAccess, x, y, z, sim ) ) { rbw.populate( sim ); rbw.faces = EnumSet.allOf( ForgeDirection.class ); @@ -217,7 +303,11 @@ public class BusRenderHelper implements IPartRenderHelper this.setBounds( this.bbc.minX, this.bbc.minY, this.bbc.minZ, this.bbc.maxX, this.bbc.maxY, this.bbc.maxZ ); this.bbr.renderBlockBounds( rbw, this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ, this.ax, this.ay, this.az ); - rbw.renderStandardBlock( this.blk, x, y, z ); + + for ( Block block : this.maybeBlock.asSet() ) + { + rbw.renderStandardBlock( block, x, y, z ); + } rbw.faces = EnumSet.allOf( ForgeDirection.class ); rbw.renderAllFaces = allFaces; @@ -229,7 +319,7 @@ public class BusRenderHelper implements IPartRenderHelper } @Override - public void setBounds(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) + public void setBounds( float minX, float minY, float minZ, float maxX, float maxY, float maxZ ) { this.minX = minX; this.minY = minY; @@ -239,43 +329,23 @@ public class BusRenderHelper implements IPartRenderHelper this.maxZ = maxZ; } - public double getBound(ForgeDirection side) - { - switch (side) - { - default: - case UNKNOWN: - return 0.5; - case DOWN: - return this.minY; - case EAST: - return this.maxX; - case NORTH: - return this.minZ; - case SOUTH: - return this.maxZ; - case UP: - return this.maxY; - case WEST: - return this.minX; - - } - } - @Override - public void setInvColor(int newColor) + public void setInvColor( int newColor ) { this.color = newColor; } @Override - public void setTexture(IIcon ico) + public void setTexture( IIcon ico ) { - this.blk.getRendererInstance().setTemporaryRenderIcon( ico ); + for ( AEBaseBlock baseBlock : this.maybeBaseBlock.asSet() ) + { + baseBlock.getRendererInstance().setTemporaryRenderIcon( ico ); + } } @Override - public void setTexture(IIcon Down, IIcon Up, IIcon North, IIcon South, IIcon West, IIcon East) + public void setTexture( IIcon Down, IIcon Up, IIcon North, IIcon South, IIcon West, IIcon East ) { IIcon[] list = new IIcon[6]; @@ -286,13 +356,13 @@ public class BusRenderHelper implements IPartRenderHelper list[4] = West; list[5] = East; - this.blk.getRendererInstance().setTemporaryRenderIcons( list[this.mapRotation( ForgeDirection.UP ).ordinal()], - list[this.mapRotation( ForgeDirection.DOWN ).ordinal()], list[this.mapRotation( ForgeDirection.SOUTH ).ordinal()], - list[this.mapRotation( ForgeDirection.NORTH ).ordinal()], list[this.mapRotation( ForgeDirection.EAST ).ordinal()], - list[this.mapRotation( ForgeDirection.WEST ).ordinal()] ); + for ( AEBaseBlock baseBlock : this.maybeBaseBlock.asSet() ) + { + baseBlock.getRendererInstance().setTemporaryRenderIcons( list[this.mapRotation( ForgeDirection.UP ).ordinal()], list[this.mapRotation( ForgeDirection.DOWN ).ordinal()], list[this.mapRotation( ForgeDirection.SOUTH ).ordinal()], list[this.mapRotation( ForgeDirection.NORTH ).ordinal()], list[this.mapRotation( ForgeDirection.EAST ).ordinal()], list[this.mapRotation( ForgeDirection.WEST ).ordinal()] ); + } } - public ForgeDirection mapRotation(ForgeDirection dir) + public ForgeDirection mapRotation( ForgeDirection dir ) { ForgeDirection forward = this.az; ForgeDirection up = this.ay; @@ -305,7 +375,7 @@ public class BusRenderHelper implements IPartRenderHelper int west_y = forward.offsetZ * up.offsetX - forward.offsetX * up.offsetZ; int west_z = forward.offsetX * up.offsetY - forward.offsetY * up.offsetX; - for (ForgeDirection dx : ForgeDirection.VALID_DIRECTIONS) + for ( ForgeDirection dx : ForgeDirection.VALID_DIRECTIONS ) if ( dx.offsetX == west_x && dx.offsetY == west_y && dx.offsetZ == west_z ) west = dx; @@ -328,146 +398,166 @@ public class BusRenderHelper implements IPartRenderHelper } @Override - public void renderInventoryBox(RenderBlocks renderer) + public void renderInventoryBox( RenderBlocks renderer ) { renderer.setRenderBounds( this.minX / 16.0, this.minY / 16.0, this.minZ / 16.0, this.maxX / 16.0, this.maxY / 16.0, this.maxZ / 16.0 ); - this.bbr.renderInvBlock( EnumSet.allOf( ForgeDirection.class ), this.blk, null, Tessellator.instance, this.color, renderer ); + + for ( AEBaseBlock baseBlock : this.maybeBaseBlock.asSet() ) + { + this.bbr.renderInvBlock( EnumSet.allOf( ForgeDirection.class ), baseBlock, null, Tessellator.instance, this.color, renderer ); + } } @Override - public void renderInventoryFace(IIcon IIcon, ForgeDirection face, RenderBlocks renderer) + public void renderInventoryFace( IIcon IIcon, ForgeDirection face, RenderBlocks renderer ) { renderer.setRenderBounds( this.minX / 16.0, this.minY / 16.0, this.minZ / 16.0, this.maxX / 16.0, this.maxY / 16.0, this.maxZ / 16.0 ); this.setTexture( IIcon ); - this.bbr.renderInvBlock( EnumSet.of( face ), this.blk, null, Tessellator.instance, this.color, renderer ); + + for ( AEBaseBlock baseBlock : this.maybeBaseBlock.asSet() ) + { + this.bbr.renderInvBlock( EnumSet.of( face ), baseBlock, null, Tessellator.instance, this.color, renderer ); + } } @Override - public void renderBlock(int x, int y, int z, RenderBlocks renderer) + public void renderBlock( int x, int y, int z, RenderBlocks renderer ) { if ( !this.renderThis() ) return; - AEBaseBlock blk = (AEBaseBlock) AEApi.instance().blocks().blockMultiPart.block(); - BlockRenderInfo info = blk.getRendererInstance(); - ForgeDirection forward = BusRenderHelper.INSTANCE.az; - ForgeDirection up = BusRenderHelper.INSTANCE.ay; + for ( Block multiPart : AEApi.instance().definitions().blocks().multiPart().maybeBlock().asSet() ) + { + final AEBaseBlock block = (AEBaseBlock) multiPart; - renderer.uvRotateBottom = info.getTexture( ForgeDirection.DOWN ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.DOWN, forward, up ) ); - renderer.uvRotateTop = info.getTexture( ForgeDirection.UP ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.UP, forward, up ) ); + BlockRenderInfo info = block.getRendererInstance(); + ForgeDirection forward = BusRenderHelper.INSTANCE.az; + ForgeDirection up = BusRenderHelper.INSTANCE.ay; - renderer.uvRotateEast = info.getTexture( ForgeDirection.EAST ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.EAST, forward, up ) ); - renderer.uvRotateWest = info.getTexture( ForgeDirection.WEST ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.WEST, forward, up ) ); + renderer.uvRotateBottom = info.getTexture( ForgeDirection.DOWN ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.DOWN, forward, up ) ); + renderer.uvRotateTop = info.getTexture( ForgeDirection.UP ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.UP, forward, up ) ); - renderer.uvRotateNorth = info.getTexture( ForgeDirection.NORTH ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.NORTH, forward, up ) ); - renderer.uvRotateSouth = info.getTexture( ForgeDirection.SOUTH ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.SOUTH, forward, up ) ); + renderer.uvRotateEast = info.getTexture( ForgeDirection.EAST ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.EAST, forward, up ) ); + renderer.uvRotateWest = info.getTexture( ForgeDirection.WEST ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.WEST, forward, up ) ); - this.bbr.renderBlockBounds( renderer, this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ, this.ax, this.ay, this.az ); + renderer.uvRotateNorth = info.getTexture( ForgeDirection.NORTH ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.NORTH, forward, up ) ); + renderer.uvRotateSouth = info.getTexture( ForgeDirection.SOUTH ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.SOUTH, forward, up ) ); - renderer.renderStandardBlock( blk, x, y, z ); + this.bbr.renderBlockBounds( renderer, this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ, this.ax, this.ay, this.az ); + + renderer.renderStandardBlock( block, x, y, z ); + } } @Override public Block getBlock() { - return AEApi.instance().blocks().blockMultiPart.block(); + for ( Block block : AEApi.instance().definitions().blocks().multiPart().maybeBlock().asSet() ) + { + return block; + } + + throw new MissingDefinition( "Tried to access the multi part block." ); } - public void setRenderColor(int color) - { - BlockCableBus blk = (BlockCableBus) AEApi.instance().blocks().blockMultiPart.block(); - blk.setRenderColor( color ); - } - - public void prepareBounds(RenderBlocks renderer) + public void prepareBounds( RenderBlocks renderer ) { this.bbr.renderBlockBounds( renderer, this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ, this.ax, this.ay, this.az ); } @Override - public void setFacesToRender(EnumSet faces) + public void setFacesToRender( EnumSet faces ) { BusRenderer.INSTANCE.renderer.renderFaces = faces; } @Override - public void renderBlockCurrentBounds(int x, int y, int z, RenderBlocks renderer) + public void renderBlockCurrentBounds( int x, int y, int z, RenderBlocks renderer ) { if ( !this.renderThis() ) return; - renderer.renderStandardBlock( this.blk, x, y, z ); + for ( Block block : this.maybeBlock.asSet() ) + { + renderer.renderStandardBlock( block, x, y, z ); + } } @Override - public void renderFaceCutout(int x, int y, int z, IIcon ico, ForgeDirection face, float edgeThickness, RenderBlocks renderer) + public void renderFaceCutout( int x, int y, int z, IIcon ico, ForgeDirection face, float edgeThickness, RenderBlocks renderer ) { if ( !this.renderThis() ) return; - switch (face) + switch ( face ) { - case DOWN: - face = this.ay.getOpposite(); - break; - case EAST: - face = this.ax; - break; - case NORTH: - face = this.az.getOpposite(); - break; - case SOUTH: - face = this.az; - break; - case UP: - face = this.ay; - break; - case WEST: - face = this.ax.getOpposite(); - break; - case UNKNOWN: - break; - default: - break; + case DOWN: + face = this.ay.getOpposite(); + break; + case EAST: + face = this.ax; + break; + case NORTH: + face = this.az.getOpposite(); + break; + case SOUTH: + face = this.az; + break; + case UP: + face = this.ay; + break; + case WEST: + face = this.ax.getOpposite(); + break; + case UNKNOWN: + break; + default: + break; } - this.bbr.renderCutoutFace( this.blk, ico, x, y, z, renderer, face, edgeThickness ); + for ( Block block : this.maybeBlock.asSet() ) + { + this.bbr.renderCutoutFace( block, ico, x, y, z, renderer, face, edgeThickness ); + } } @Override - public void renderFace(int x, int y, int z, IIcon ico, ForgeDirection face, RenderBlocks renderer) + public void renderFace( int x, int y, int z, IIcon ico, ForgeDirection face, RenderBlocks renderer ) { if ( !this.renderThis() ) return; this.prepareBounds( renderer ); - switch (face) + switch ( face ) { - case DOWN: - face = this.ay.getOpposite(); - break; - case EAST: - face = this.ax; - break; - case NORTH: - face = this.az.getOpposite(); - break; - case SOUTH: - face = this.az; - break; - case UP: - face = this.ay; - break; - case WEST: - face = this.ax.getOpposite(); - break; - case UNKNOWN: - break; - default: - break; + case DOWN: + face = this.ay.getOpposite(); + break; + case EAST: + face = this.ax; + break; + case NORTH: + face = this.az.getOpposite(); + break; + case SOUTH: + face = this.az; + break; + case UP: + face = this.ay; + break; + case WEST: + face = this.ax.getOpposite(); + break; + case UNKNOWN: + break; + default: + break; } - this.bbr.renderFace( x, y, z, this.blk, ico, renderer, face ); + for ( Block block : this.maybeBlock.asSet() ) + { + this.bbr.renderFace( x, y, z, block, ico, renderer, face ); + } } @Override @@ -488,29 +578,18 @@ public class BusRenderHelper implements IPartRenderHelper return this.az; } - public void setOrientation(ForgeDirection dx, ForgeDirection dy, ForgeDirection dz) + private static final class BaseBlockTransformFunction implements Function { - this.ax = dx == null ? ForgeDirection.EAST : dx; - this.ay = dy == null ? ForgeDirection.UP : dy; - this.az = dz == null ? ForgeDirection.SOUTH : dz; + @Nullable + @Override + public AEBaseBlock apply( Block input ) + { + if ( input instanceof AEBaseBlock ) + { + return ( (AEBaseBlock) input ); + } + + return null; + } } - - public double[] getBounds() - { - return new double[] { this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ }; - } - - public void setBounds(double[] bounds) - { - if ( bounds == null || bounds.length != 6 ) - return; - - this.minX = bounds[0]; - this.minY = bounds[1]; - this.minZ = bounds[2]; - this.maxX = bounds[3]; - this.maxY = bounds[4]; - this.maxZ = bounds[5]; - } - } diff --git a/src/main/java/appeng/client/render/blocks/RenderBlockCraftingCPU.java b/src/main/java/appeng/client/render/blocks/RenderBlockCraftingCPU.java index f6c8e6bc9..4c5309415 100644 --- a/src/main/java/appeng/client/render/blocks/RenderBlockCraftingCPU.java +++ b/src/main/java/appeng/client/render/blocks/RenderBlockCraftingCPU.java @@ -20,6 +20,7 @@ package appeng.client.render.blocks; import java.util.EnumSet; +import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.tileentity.TileEntity; @@ -70,7 +71,12 @@ public class RenderBlockCraftingCPU extends BaseBlockRender IIcon nonForward = theIcon; if ( isMonitor ) - nonForward = AEApi.instance().blocks().blockCraftingUnit.block().getIcon( 0, meta | (formed ? 8 : 0) ); + { + for ( Block craftingBlock : AEApi.instance().definitions().blocks().craftingUnit().maybeBlock().asSet() ) + { + nonForward = craftingBlock.getIcon( 0, meta | ( formed ? 8 : 0 ) ); + } + } if ( formed && renderer.overrideBlockTexture == null ) { diff --git a/src/main/java/appeng/client/render/blocks/RenderQNB.java b/src/main/java/appeng/client/render/blocks/RenderQNB.java index 025a79da4..d4b1aecde 100644 --- a/src/main/java/appeng/client/render/blocks/RenderQNB.java +++ b/src/main/java/appeng/client/render/blocks/RenderQNB.java @@ -18,8 +18,10 @@ package appeng.client.render.blocks; +import java.util.Collection; import java.util.EnumSet; +import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.item.Item; @@ -30,8 +32,10 @@ import net.minecraftforge.client.IItemRenderer.ItemRenderType; import net.minecraftforge.common.util.ForgeDirection; import appeng.api.AEApi; +import appeng.api.definitions.IBlocks; +import appeng.api.definitions.IDefinitions; +import appeng.api.definitions.IParts; import appeng.api.util.AEColor; -import appeng.api.util.AEColoredItemDefinition; import appeng.block.AEBaseBlock; import appeng.client.render.BaseBlockRender; import appeng.client.texture.ExtraBlockTextures; @@ -40,50 +44,50 @@ import appeng.tile.qnb.TileQuantumBridge; public class RenderQNB extends BaseBlockRender { - public void renderCableAt(double Thickness, IBlockAccess world, int x, int y, int z, AEBaseBlock block, RenderBlocks renderer, IIcon texture, double pull, - EnumSet connections) + public void renderCableAt(double thickness, IBlockAccess world, int x, int y, int z, AEBaseBlock block, RenderBlocks renderer, IIcon texture, double pull, + Collection connections) { block.getRendererInstance().setTemporaryRenderIcon( texture ); if ( connections.contains( ForgeDirection.UNKNOWN ) ) { - renderer.setRenderBounds( 0.5D - Thickness, 0.5D - Thickness, 0.5D - Thickness, 0.5D + Thickness, 0.5D + Thickness, 0.5D + Thickness ); + renderer.setRenderBounds( 0.5D - thickness, 0.5D - thickness, 0.5D - thickness, 0.5D + thickness, 0.5D + thickness, 0.5D + thickness ); renderer.renderStandardBlock( block, x, y, z ); } if ( connections.contains( ForgeDirection.WEST ) ) { - renderer.setRenderBounds( 0.0D, 0.5D - Thickness, 0.5D - Thickness, 0.5D - Thickness - pull, 0.5D + Thickness, 0.5D + Thickness ); + renderer.setRenderBounds( 0.0D, 0.5D - thickness, 0.5D - thickness, 0.5D - thickness - pull, 0.5D + thickness, 0.5D + thickness ); renderer.renderStandardBlock( block, x, y, z ); } if ( connections.contains( ForgeDirection.EAST ) ) { - renderer.setRenderBounds( 0.5D + Thickness + pull, 0.5D - Thickness, 0.5D - Thickness, 1.0D, 0.5D + Thickness, 0.5D + Thickness ); + renderer.setRenderBounds( 0.5D + thickness + pull, 0.5D - thickness, 0.5D - thickness, 1.0D, 0.5D + thickness, 0.5D + thickness ); renderer.renderStandardBlock( block, x, y, z ); } if ( connections.contains( ForgeDirection.NORTH ) ) { - renderer.setRenderBounds( 0.5D - Thickness, 0.5D - Thickness, 0.0D, 0.5D + Thickness, 0.5D + Thickness, 0.5D - Thickness - pull ); + renderer.setRenderBounds( 0.5D - thickness, 0.5D - thickness, 0.0D, 0.5D + thickness, 0.5D + thickness, 0.5D - thickness - pull ); renderer.renderStandardBlock( block, x, y, z ); } if ( connections.contains( ForgeDirection.SOUTH ) ) { - renderer.setRenderBounds( 0.5D - Thickness, 0.5D - Thickness, 0.5D + Thickness + pull, 0.5D + Thickness, 0.5D + Thickness, 1.0D ); + renderer.setRenderBounds( 0.5D - thickness, 0.5D - thickness, 0.5D + thickness + pull, 0.5D + thickness, 0.5D + thickness, 1.0D ); renderer.renderStandardBlock( block, x, y, z ); } if ( connections.contains( ForgeDirection.DOWN ) ) { - renderer.setRenderBounds( 0.5D - Thickness, 0.0D, 0.5D - Thickness, 0.5D + Thickness, 0.5D - Thickness - pull, 0.5D + Thickness ); + renderer.setRenderBounds( 0.5D - thickness, 0.0D, 0.5D - thickness, 0.5D + thickness, 0.5D - thickness - pull, 0.5D + thickness ); renderer.renderStandardBlock( block, x, y, z ); } if ( connections.contains( ForgeDirection.UP ) ) { - renderer.setRenderBounds( 0.5D - Thickness, 0.5D + Thickness + pull, 0.5D - Thickness, 0.5D + Thickness, 1.0D, 0.5D + Thickness ); + renderer.setRenderBounds( 0.5D - thickness, 0.5D + thickness + pull, 0.5D - thickness, 0.5D + thickness, 1.0D, 0.5D + thickness ); renderer.renderStandardBlock( block, x, y, z ); } @@ -109,92 +113,91 @@ public class RenderQNB extends BaseBlockRender renderer.renderAllFaces = true; - if ( tqb.getBlockType() == AEApi.instance().blocks().blockQuantumLink.block() ) + final IDefinitions definitions = AEApi.instance().definitions(); + final IBlocks blocks = definitions.blocks(); + final IParts parts = definitions.parts(); + + for ( Block linkBlock : blocks.quantumLink().maybeBlock().asSet() ) { - if ( tqb.isFormed() ) + if ( tqb.getBlockType() == linkBlock ) { - AEColoredItemDefinition glassCableDefinition = AEApi.instance().parts().partCableGlass; - Item transparentGlassCable = glassCableDefinition.item( AEColor.Transparent ); + if ( tqb.isFormed() ) + { + EnumSet sides = tqb.getConnections(); - AEColoredItemDefinition coveredCableDefinition = AEApi.instance().parts().partCableCovered; - Item transparentCoveredCable = coveredCableDefinition.item( AEColor.Transparent ); + Item transGlassCable = parts.cableGlass().item( AEColor.Transparent ); + this.renderCableAt( 0.11D, world, x, y, z, block, renderer, transGlassCable.getIconIndex( parts.cableGlass().stack( AEColor.Transparent, 1 ) ), 0.141D, sides ); - EnumSet sides = tqb.getConnections(); - this.renderCableAt( 0.11D, world, x, y, z, block, renderer, transparentGlassCable.getIconIndex( glassCableDefinition.stack( AEColor.Transparent, 1 ) ), 0.141D, sides ); - this.renderCableAt( 0.188D, world, x, y, z, block, renderer, transparentCoveredCable.getIconIndex( coveredCableDefinition.stack( AEColor.Transparent, 1 ) ), 0.1875D, sides ); - } + Item transCoveredCable = parts.cableCovered().item( AEColor.Transparent ); + this.renderCableAt( 0.188D, world, x, y, z, block, renderer, transCoveredCable.getIconIndex( parts.cableCovered().stack( AEColor.Transparent, 1 ) ), 0.1875D, sides ); + } - float renderMin = 2.0f / 16.0f; - float renderMax = 14.0f / 16.0f; - renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax ); - renderer.renderStandardBlock( block, x, y, z ); - // super.renderWorldBlock(world, x, y, z, block, modelId, renderer); - } - else - { - if ( !tqb.isFormed() ) - { float renderMin = 2.0f / 16.0f; float renderMax = 14.0f / 16.0f; renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax ); renderer.renderStandardBlock( block, x, y, z ); } - else if ( tqb.isCorner() ) - { - // renderCableAt(0.11D, world, x, y, z, block, modelId, - // renderer, - // AppEngTextureRegistry.Blocks.MECable.get(), true, 0.0D); - AEColoredItemDefinition coveredCableDefinition = AEApi.instance().parts().partCableCovered; - Item transparentCoveredCable = coveredCableDefinition.item( AEColor.Transparent ); - - this.renderCableAt( 0.188D, world, x, y, z, block, renderer, transparentCoveredCable.getIconIndex( coveredCableDefinition.stack( AEColor.Transparent, 1 ) ), 0.05D, - tqb.getConnections() ); - - float renderMin = 4.0f / 16.0f; - float renderMax = 12.0f / 16.0f; - - renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax ); - renderer.renderStandardBlock( block, x, y, z ); - - if ( tqb.isPowered() ) - { - - renderMin = 3.9f / 16.0f; - renderMax = 12.1f / 16.0f; - renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax ); - - int bn = 15; - Tessellator.instance.setColorOpaque_F( 1.0F, 1.0F, 1.0F ); - Tessellator.instance.setBrightness( bn << 20 | bn << 4 ); - for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - this.renderFace( x, y, z, block, ExtraBlockTextures.BlockQRingCornerLight.getIcon(), renderer, side ); - - } - } else { - float renderMin = 2.0f / 16.0f; - float renderMax = 14.0f / 16.0f; - renderer.setRenderBounds( 0, renderMin, renderMin, 1, renderMax, renderMax ); - renderer.renderStandardBlock( block, x, y, z ); - - renderer.setRenderBounds( renderMin, 0, renderMin, renderMax, 1, renderMax ); - renderer.renderStandardBlock( block, x, y, z ); - - renderer.setRenderBounds( renderMin, renderMin, 0, renderMax, renderMax, 1 ); - renderer.renderStandardBlock( block, x, y, z ); - - if ( tqb.isPowered() ) + if ( !tqb.isFormed() ) { - renderMin = -0.01f / 16.0f; - renderMax = 16.01f / 16.0f; + float renderMin = 2.0f / 16.0f; + float renderMax = 14.0f / 16.0f; renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax ); + renderer.renderStandardBlock( block, x, y, z ); + } + else if ( tqb.isCorner() ) + { + Item transCoveredCable = parts.cableCovered().item( AEColor.Transparent ); + this.renderCableAt( 0.188D, world, x, y, z, block, renderer, transCoveredCable.getIconIndex( parts.cableCovered().stack( AEColor.Transparent, 1 ) ), 0.05D, + tqb.getConnections() ); - int bn = 15; - Tessellator.instance.setColorOpaque_F( 1.0F, 1.0F, 1.0F ); - Tessellator.instance.setBrightness( bn << 20 | bn << 4 ); - for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - this.renderFace( x, y, z, block, ExtraBlockTextures.BlockQRingEdgeLight.getIcon(), renderer, side ); + float renderMin = 4.0f / 16.0f; + float renderMax = 12.0f / 16.0f; + + renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax ); + renderer.renderStandardBlock( block, x, y, z ); + + if ( tqb.isPowered() ) + { + + renderMin = 3.9f / 16.0f; + renderMax = 12.1f / 16.0f; + renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax ); + + int bn = 15; + Tessellator.instance.setColorOpaque_F( 1.0F, 1.0F, 1.0F ); + Tessellator.instance.setBrightness( bn << 20 | bn << 4 ); + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) + this.renderFace( x, y, z, block, ExtraBlockTextures.BlockQRingCornerLight.getIcon(), renderer, side ); + + } + } + else + { + float renderMin = 2.0f / 16.0f; + float renderMax = 14.0f / 16.0f; + renderer.setRenderBounds( 0, renderMin, renderMin, 1, renderMax, renderMax ); + renderer.renderStandardBlock( block, x, y, z ); + + renderer.setRenderBounds( renderMin, 0, renderMin, renderMax, 1, renderMax ); + renderer.renderStandardBlock( block, x, y, z ); + + renderer.setRenderBounds( renderMin, renderMin, 0, renderMax, renderMax, 1 ); + renderer.renderStandardBlock( block, x, y, z ); + + if ( tqb.isPowered() ) + { + renderMin = -0.01f / 16.0f; + renderMax = 16.01f / 16.0f; + renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax ); + + int bn = 15; + Tessellator.instance.setColorOpaque_F( 1.0F, 1.0F, 1.0F ); + Tessellator.instance.setBrightness( bn << 20 | bn << 4 ); + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) + this.renderFace( x, y, z, block, ExtraBlockTextures.BlockQRingEdgeLight.getIcon(), renderer, side ); + } } } } diff --git a/src/main/java/appeng/client/render/blocks/RenderQuartzGlass.java b/src/main/java/appeng/client/render/blocks/RenderQuartzGlass.java index a07c43976..d5c37277f 100644 --- a/src/main/java/appeng/client/render/blocks/RenderQuartzGlass.java +++ b/src/main/java/appeng/client/render/blocks/RenderQuartzGlass.java @@ -56,8 +56,17 @@ public class RenderQuartzGlass extends BaseBlockRender boolean isGlass(AEBaseBlock imb, IBlockAccess world, int x, int y, int z) { - return world.getBlock( x, y, z ) == AEApi.instance().blocks().blockQuartzGlass.block() - || world.getBlock( x, y, z ) == AEApi.instance().blocks().blockQuartzVibrantGlass.block(); + return this.isQuartzGlass( world, x, y, z ) || this.isVibrantQuartzGlass( world, x, y, z ); + } + + private boolean isQuartzGlass( IBlockAccess world, int x, int y, int z ) + { + return AEApi.instance().definitions().blocks().quartzGlass().isSameAs( world, x, y, z ); + } + + private boolean isVibrantQuartzGlass( IBlockAccess world, int x, int y, int z ) + { + return AEApi.instance().definitions().blocks().quartzVibrantGlass().isSameAs( world, x, y, z ); } void renderEdge(AEBaseBlock imb, IBlockAccess world, int x, int y, int z, RenderBlocks renderer, ForgeDirection side, ForgeDirection direction) diff --git a/src/main/java/appeng/client/render/blocks/RenderQuartzOre.java b/src/main/java/appeng/client/render/blocks/RenderQuartzOre.java index 06040d755..79405ecc0 100644 --- a/src/main/java/appeng/client/render/blocks/RenderQuartzOre.java +++ b/src/main/java/appeng/client/render/blocks/RenderQuartzOre.java @@ -48,9 +48,9 @@ public class RenderQuartzOre extends BaseBlockRender public boolean renderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer) { OreQuartz blk = (OreQuartz) block; - blk.enhanceBrightness = true; + blk.setEnhanceBrightness( true ); super.renderInWorld( block, world, x, y, z, renderer ); - blk.enhanceBrightness = false; + blk.setEnhanceBrightness( false ); blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.OreQuartzStone.getIcon() ); boolean out = super.renderInWorld( block, world, x, y, z, renderer ); diff --git a/src/main/java/appeng/container/implementations/ContainerInscriber.java b/src/main/java/appeng/container/implementations/ContainerInscriber.java index 97a2560b0..d81c1c67a 100644 --- a/src/main/java/appeng/container/implementations/ContainerInscriber.java +++ b/src/main/java/appeng/container/implementations/ContainerInscriber.java @@ -23,6 +23,7 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import appeng.api.AEApi; +import appeng.api.definitions.IItemDefinition; import appeng.container.guisync.GuiSync; import appeng.container.interfaces.IProgressProvider; import appeng.container.slot.SlotOutput; @@ -140,8 +141,11 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres otherSlot = this.top.getStack(); // name presses - if ( AEApi.instance().materials().materialNamePress.sameAsStack( otherSlot ) ) - return AEApi.instance().materials().materialNamePress.sameAsStack( is ); + final IItemDefinition namePress = AEApi.instance().definitions().materials().namePress(); + if ( namePress.isSameAs( otherSlot ) ) + { + return namePress.isSameAs( is ); + } // everything else for (InscriberRecipe i : Inscribe.RECIPES ) diff --git a/src/main/java/appeng/container/implementations/ContainerMEMonitorable.java b/src/main/java/appeng/container/implementations/ContainerMEMonitorable.java index ee46385d7..4ef799e17 100644 --- a/src/main/java/appeng/container/implementations/ContainerMEMonitorable.java +++ b/src/main/java/appeng/container/implementations/ContainerMEMonitorable.java @@ -163,10 +163,10 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa if ( this.monitor != this.host.getItemInventory() ) this.isContainerValid = false; - for (Enum set : this.serverCM.getSettings()) + for (Settings set : this.serverCM.getSettings()) { - Enum sideLocal = this.serverCM.getSetting( set ); - Enum sideRemote = this.clientCM.getSetting( set ); + Enum sideLocal = this.serverCM.getSetting( set ); + Enum sideRemote = this.clientCM.getSetting( set ); if ( sideLocal != sideRemote ) { diff --git a/src/main/java/appeng/container/implementations/ContainerPatternTerm.java b/src/main/java/appeng/container/implementations/ContainerPatternTerm.java index 7e5274f05..65edc0fe3 100644 --- a/src/main/java/appeng/container/implementations/ContainerPatternTerm.java +++ b/src/main/java/appeng/container/implementations/ContainerPatternTerm.java @@ -39,6 +39,7 @@ import net.minecraftforge.common.util.ForgeDirection; import appeng.api.AEApi; import appeng.api.config.Actionable; +import appeng.api.definitions.IDefinitions; import appeng.api.networking.security.MachineSource; import appeng.api.storage.IMEMonitor; import appeng.api.storage.ITerminalHost; @@ -218,7 +219,11 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA this.patternSlotIN.putStack( null ); // add a new encoded pattern. - this.patternSlotOUT.putStack( output = AEApi.instance().items().itemEncodedPattern.stack( 1 ) ); + for ( ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() ) + { + output = encodedPatternStack; + this.patternSlotOUT.putStack( output ); + } } // encode the slot. @@ -303,7 +308,12 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA if ( output == null ) return false; - return AEApi.instance().items().itemEncodedPattern.sameAsStack( output ) || AEApi.instance().materials().materialBlankPattern.sameAsStack( output ); + final IDefinitions definitions = AEApi.instance().definitions(); + + boolean isPattern = definitions.items().encodedPattern().isSameAs( output ); + isPattern |= definitions.materials().blankPattern().isSameAs( output ); + + return isPattern; } @Override diff --git a/src/main/java/appeng/container/implementations/ContainerQuartzKnife.java b/src/main/java/appeng/container/implementations/ContainerQuartzKnife.java index 07d9947f0..cb29983f7 100644 --- a/src/main/java/appeng/container/implementations/ContainerQuartzKnife.java +++ b/src/main/java/appeng/container/implementations/ContainerQuartzKnife.java @@ -120,10 +120,13 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn { if ( this.myName.length() > 0 ) { - ItemStack name = AEApi.instance().materials().materialNamePress.stack( 1 ); - NBTTagCompound c = Platform.openNbtData( name ); - c.setString( "InscribeName", this.myName ); - return name; + for ( ItemStack namePressStack : AEApi.instance().definitions().materials().namePress().maybeStack( 1 ).asSet() ) + { + final NBTTagCompound compound = Platform.openNbtData( namePressStack ); + compound.setString( "InscribeName", this.myName ); + + return namePressStack; + } } } diff --git a/src/main/java/appeng/container/slot/SlotRestrictedInput.java b/src/main/java/appeng/container/slot/SlotRestrictedInput.java index ca7c06505..81f35b0ad 100644 --- a/src/main/java/appeng/container/slot/SlotRestrictedInput.java +++ b/src/main/java/appeng/container/slot/SlotRestrictedInput.java @@ -29,7 +29,9 @@ import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; import appeng.api.AEApi; -import appeng.api.IAppEngApi; +import appeng.api.definitions.IDefinitions; +import appeng.api.definitions.IItems; +import appeng.api.definitions.IMaterials; import appeng.api.features.INetworkEncodable; import appeng.api.implementations.ICraftingPatternItem; import appeng.api.implementations.items.IBiometricCard; @@ -80,9 +82,7 @@ public class SlotRestrictedInput extends AppEngSlot { ICraftingPatternDetails ap = is.getItem() instanceof ICraftingPatternItem ? ((ICraftingPatternItem) is.getItem()).getPatternForItem( is, theWorld ) : null; - if ( ap != null ) - return true; - return false; + return ap != null; } return true; } @@ -142,96 +142,101 @@ public class SlotRestrictedInput extends AppEngSlot if ( !this.inventory.isItemValidForSlot( this.getSlotIndex(), i ) ) return false; - IAppEngApi api = AEApi.instance(); - if ( !this.allowEdit ) return false; + final IDefinitions definitions = AEApi.instance().definitions(); + final IMaterials materials = definitions.materials(); + final IItems items = definitions.items(); + switch (this.which) { - case ENCODED_CRAFTING_PATTERN: - if ( i.getItem() instanceof ICraftingPatternItem ) - { - ICraftingPatternItem b = (ICraftingPatternItem) i.getItem(); - ICraftingPatternDetails de = b.getPatternForItem( i, this.p.player.worldObj ); - if ( de != null ) - return de.isCraftable(); + case ENCODED_CRAFTING_PATTERN: + if ( i.getItem() instanceof ICraftingPatternItem ) + { + ICraftingPatternItem b = (ICraftingPatternItem) i.getItem(); + ICraftingPatternDetails de = b.getPatternForItem( i, this.p.player.worldObj ); + if ( de != null ) + return de.isCraftable(); + } + return false; + case VALID_ENCODED_PATTERN_W_OUTPUT: + case ENCODED_PATTERN_W_OUTPUT: + case ENCODED_PATTERN: { + if ( i.getItem() instanceof ICraftingPatternItem ) + return true; + // ICraftingPatternDetails pattern = i.getItem() instanceof ICraftingPatternItem ? ((ICraftingPatternItem) + // i.getItem()).getPatternForItem( i ) : null; + return false;// pattern != null; } - return false; - case VALID_ENCODED_PATTERN_W_OUTPUT: - case ENCODED_PATTERN_W_OUTPUT: - case ENCODED_PATTERN: { - if ( i.getItem() instanceof ICraftingPatternItem ) - return true; - // ICraftingPatternDetails pattern = i.getItem() instanceof ICraftingPatternItem ? ((ICraftingPatternItem) - // i.getItem()).getPatternForItem( i ) : null; - return false;// pattern != null; - } - case BLANK_PATTERN: - return AEApi.instance().materials().materialBlankPattern.sameAsStack( i ); - case PATTERN: + case BLANK_PATTERN: + return materials.blankPattern().isSameAs( i ); - if ( i.getItem() instanceof ICraftingPatternItem ) - return true; + case PATTERN: - return AEApi.instance().materials().materialBlankPattern.sameAsStack( i ); - - case INSCRIBER_PLATE: - - if ( AEApi.instance().materials().materialNamePress.sameAsStack( i ) ) - return true; - - for (ItemStack is : Inscribe.PLATES ) - if ( Platform.isSameItemPrecise( is, i ) ) + if ( i.getItem() instanceof ICraftingPatternItem ) return true; - return false; + return materials.blankPattern().isSameAs( i ); - case INSCRIBER_INPUT: - return true;/* - * for (ItemStack is : Inscribe.inputs) if ( Platform.isSameItemPrecise( is, i ) ) return true; - * - * return false; - */ + case INSCRIBER_PLATE: + if ( materials.namePress().isSameAs( i ) ) + { + return true; + } - case METAL_INGOTS: + for (ItemStack is : Inscribe.PLATES ) + if ( Platform.isSameItemPrecise( is, i ) ) + return true; - return isMetalIngot( i ); - - case VIEW_CELL: - return AEApi.instance().items().itemViewCell.sameAsStack( i ); - case ORE: - return appeng.api.AEApi.instance().registries().grinder().getRecipeForInput( i ) != null; - case FUEL: - return TileEntityFurnace.getItemBurnTime( i ) > 0; - case POWERED_TOOL: - return Platform.isChargeable( i ); - case QE_SINGULARITY: - return api.materials().materialQESingularity.sameAsStack( i ); - case RANGE_BOOSTER: - return api.materials().materialWirelessBooster.sameAsStack( i ); - case SPATIAL_STORAGE_CELLS: - return i.getItem() instanceof ISpatialStorageCell && ((ISpatialStorageCell) i.getItem()).isSpatialStorage( i ); - case STORAGE_CELLS: - return AEApi.instance().registries().cell().isCellHandled( i ); - case WORKBENCH_CELL: - return i.getItem() instanceof ICellWorkbenchItem && ((ICellWorkbenchItem) i.getItem()).isEditable( i ); - case STORAGE_COMPONENT: - return i.getItem() instanceof IStorageComponent && ((IStorageComponent) i.getItem()).isStorageComponent( i ); - case TRASH: - if ( AEApi.instance().registries().cell().isCellHandled( i ) ) return false; - if ( i.getItem() instanceof IStorageComponent && ((IStorageComponent) i.getItem()).isStorageComponent( i ) ) - return false; - return true; - case ENCODABLE_ITEM: - return i.getItem() instanceof INetworkEncodable || AEApi.instance().registries().wireless().isWirelessTerminal( i ); - case BIOMETRIC_CARD: - return i.getItem() instanceof IBiometricCard; - case UPGRADES: - return i.getItem() instanceof IUpgradeModule && ((IUpgradeModule) i.getItem()).getType( i ) != null; - default: - break; + + case INSCRIBER_INPUT: + return true;/* + * for (ItemStack is : Inscribe.inputs) if ( Platform.isSameItemPrecise( is, i ) ) return true; + * + * return false; + */ + + case METAL_INGOTS: + + return isMetalIngot( i ); + + case VIEW_CELL: + return items.viewCell().isSameAs( i ); + case ORE: + return appeng.api.AEApi.instance().registries().grinder().getRecipeForInput( i ) != null; + case FUEL: + return TileEntityFurnace.getItemBurnTime( i ) > 0; + case POWERED_TOOL: + return Platform.isChargeable( i ); + case QE_SINGULARITY: + return materials.qESingularity().isSameAs( i ); + + case RANGE_BOOSTER: + return materials.wirelessBooster().isSameAs( i ); + + case SPATIAL_STORAGE_CELLS: + return i.getItem() instanceof ISpatialStorageCell && ((ISpatialStorageCell) i.getItem()).isSpatialStorage( i ); + case STORAGE_CELLS: + return AEApi.instance().registries().cell().isCellHandled( i ); + case WORKBENCH_CELL: + return i.getItem() instanceof ICellWorkbenchItem && ((ICellWorkbenchItem) i.getItem()).isEditable( i ); + case STORAGE_COMPONENT: + return i.getItem() instanceof IStorageComponent && ((IStorageComponent) i.getItem()).isStorageComponent( i ); + case TRASH: + if ( AEApi.instance().registries().cell().isCellHandled( i ) ) + return false; + + return !( i.getItem() instanceof IStorageComponent && ( (IStorageComponent) i.getItem() ).isStorageComponent( i ) ); + case ENCODABLE_ITEM: + return i.getItem() instanceof INetworkEncodable || AEApi.instance().registries().wireless().isWirelessTerminal( i ); + case BIOMETRIC_CARD: + return i.getItem() instanceof IBiometricCard; + case UPGRADES: + return i.getItem() instanceof IUpgradeModule && ((IUpgradeModule) i.getItem()).getType( i ) != null; + default: + break; } return false; diff --git a/src/main/java/appeng/core/AEConfig.java b/src/main/java/appeng/core/AEConfig.java index f25d3ba84..75372ecf9 100644 --- a/src/main/java/appeng/core/AEConfig.java +++ b/src/main/java/appeng/core/AEConfig.java @@ -193,10 +193,10 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon this.levelByStacks[btnNum] = Math.min( this.levelByStacks[btnNum], buttonCap ); } - for (Enum e : this.settings.getSettings()) + for (Settings e : this.settings.getSettings()) { String Category = "Client"; // e.getClass().getSimpleName(); - Enum value = this.settings.getSetting( e ); + Enum value = this.settings.getSetting( e ); Property p = this.get( Category, e.name(), value.name(), this.getListComment( value ) ); @@ -376,7 +376,7 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon @Override public void updateSetting(IConfigManager manager, Enum setting, Enum newValue) { - for (Enum e : this.settings.getSettings()) + for (Settings e : this.settings.getSettings()) { if ( e == setting ) { diff --git a/src/main/java/appeng/core/AELog.java b/src/main/java/appeng/core/AELog.java index 1c104f4ca..525d6065b 100644 --- a/src/main/java/appeng/core/AELog.java +++ b/src/main/java/appeng/core/AELog.java @@ -29,7 +29,7 @@ import appeng.util.Platform; public final class AELog { - public static final FMLRelaunchLog instance = FMLRelaunchLog.log; + public static final FMLRelaunchLog INSTANCE = FMLRelaunchLog.log; private AELog() { } diff --git a/src/main/java/appeng/core/Api.java b/src/main/java/appeng/core/Api.java index 2f713afea..4f87f2084 100644 --- a/src/main/java/appeng/core/Api.java +++ b/src/main/java/appeng/core/Api.java @@ -18,6 +18,7 @@ package appeng.core; + import net.minecraftforge.common.util.ForgeDirection; import appeng.api.IAppEngApi; @@ -41,28 +42,47 @@ import appeng.util.Platform; public final class Api implements IAppEngApi { - public static final Api INSTANCE = new Api(); - private Api() { - - } + private final ApiPart partHelper; // private MovableTileRegistry MovableRegistry = new MovableTileRegistry(); - private final RegistryContainer rc = new RegistryContainer(); - private final ApiStorage storageHelper = new ApiStorage(); + private final IRegistryContainer registryContainer; + private final IStorageHelper storageHelper; + private final Materials materials; + private final Items items; + private final Blocks blocks; + private final Parts parts; + private final ApiDefinitions definitions; - public final ApiPart partHelper = new ApiPart(); - - private final Materials materials = new Materials(); - private final Items items = new Items(); - private final Blocks blocks = new Blocks(); - private final Parts parts = new Parts(); + private Api() + { + this.parts = new Parts(); + this.blocks = new Blocks(); + this.items = new Items(); + this.materials = new Materials(); + this.storageHelper = new ApiStorage(); + this.registryContainer = new RegistryContainer(); + this.partHelper = new ApiPart(); + this.definitions = new ApiDefinitions( this.partHelper ); + } @Override public IRegistryContainer registries() { - return this.rc; + return this.registryContainer; + } + + @Override + public IStorageHelper storage() + { + return this.storageHelper; + } + + @Override + public IPartHelper partHelper() + { + return this.partHelper; } @Override @@ -90,19 +110,13 @@ public final class Api implements IAppEngApi } @Override - public IStorageHelper storage() + public ApiDefinitions definitions() { - return this.storageHelper; + return this.definitions; } @Override - public IPartHelper partHelper() - { - return this.partHelper; - } - - @Override - public IGridNode createGridNode(IGridBlock blk) + public IGridNode createGridNode( IGridBlock blk ) { if ( Platform.isClient() ) throw new RuntimeException( "Grid Features are Server Side Only." ); @@ -110,9 +124,13 @@ public final class Api implements IAppEngApi } @Override - public IGridConnection createGridConnection(IGridNode a, IGridNode b) throws FailedConnection + public IGridConnection createGridConnection( IGridNode a, IGridNode b ) throws FailedConnection { return new GridConnection( a, b, ForgeDirection.UNKNOWN ); } + public ApiPart getPartHelper() + { + return this.partHelper; + } } diff --git a/src/main/java/appeng/core/ApiDefinitions.java b/src/main/java/appeng/core/ApiDefinitions.java new file mode 100644 index 000000000..eb2a937e2 --- /dev/null +++ b/src/main/java/appeng/core/ApiDefinitions.java @@ -0,0 +1,89 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.core; + + +import appeng.api.definitions.IDefinitions; +import appeng.api.parts.IPartHelper; +import appeng.core.api.definitions.ApiBlocks; +import appeng.core.api.definitions.ApiItems; +import appeng.core.api.definitions.ApiMaterials; +import appeng.core.api.definitions.ApiParts; +import appeng.core.api.definitions.DefinitionConstructor; + + +/** + * Internal implementation of the definitions for the API + */ +public final class ApiDefinitions implements IDefinitions +{ + private final ApiBlocks blocks; + private final ApiItems items; + private final ApiMaterials materials; + private final ApiParts parts; + private final FeatureHandlerRegistry handlers; + private final FeatureRegistry features; + + public ApiDefinitions( IPartHelper partHelper ) + { + this.features = new FeatureRegistry(); + this.handlers = new FeatureHandlerRegistry(); + + final DefinitionConstructor constructor = new DefinitionConstructor( this.features, this.handlers ); + + this.blocks = new ApiBlocks( constructor ); + this.items = new ApiItems( constructor ); + this.materials = new ApiMaterials( constructor ); + this.parts = new ApiParts( constructor, partHelper ); + } + + public FeatureHandlerRegistry getFeatureHandlerRegistry() + { + return this.handlers; + } + + public FeatureRegistry getFeatureRegistry() + { + return this.features; + } + + @Override + public ApiBlocks blocks() + { + return this.blocks; + } + + @Override + public ApiItems items() + { + return this.items; + } + + @Override + public ApiMaterials materials() + { + return this.materials; + } + + @Override + public ApiParts parts() + { + return this.parts; + } +} diff --git a/src/main/java/appeng/core/AppEng.java b/src/main/java/appeng/core/AppEng.java index b25bf2648..530721091 100644 --- a/src/main/java/appeng/core/AppEng.java +++ b/src/main/java/appeng/core/AppEng.java @@ -193,7 +193,7 @@ public class AppEng } @EventHandler - public void serverStarting( FMLServerAboutToStartEvent evt ) + public void serverAboutToStart( FMLServerAboutToStartEvent evt ) { WorldSettings.getInstance().init(); } diff --git a/src/main/java/appeng/core/CreativeTab.java b/src/main/java/appeng/core/CreativeTab.java index 7dbb4dd7c..419e95d0e 100644 --- a/src/main/java/appeng/core/CreativeTab.java +++ b/src/main/java/appeng/core/CreativeTab.java @@ -25,15 +25,15 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import appeng.api.AEApi; -import appeng.api.IAppEngApi; -import appeng.api.definitions.Items; -import appeng.api.definitions.Materials; -import appeng.api.util.AEItemDefinition; +import appeng.api.definitions.IBlocks; +import appeng.api.definitions.IDefinitions; +import appeng.api.definitions.IItemDefinition; +import appeng.api.definitions.IItems; +import appeng.api.definitions.IMaterials; public final class CreativeTab extends CreativeTabs { - public static CreativeTab instance = null; public CreativeTab() @@ -55,25 +55,21 @@ public final class CreativeTab extends CreativeTabs @Override public ItemStack getIconItemStack() { - final IAppEngApi api = AEApi.instance(); - final appeng.api.definitions.Blocks blocks = api.blocks(); - final Items items = api.items(); - final Materials materials = api.materials(); + final IDefinitions definitions = AEApi.instance().definitions(); + final IBlocks blocks = definitions.blocks(); + final IItems items = definitions.items(); + final IMaterials materials = definitions.materials(); - return this.findFirst( blocks.blockController, blocks.blockChest, blocks.blockCellWorkbench, blocks.blockFluix, items.itemCell1k, items.itemNetworkTool, materials.materialFluixCrystal, materials.materialCertusQuartzCrystal ); + return this.findFirst( blocks.controller(), blocks.chest(), blocks.cellWorkbench(), blocks.fluix(), items.cell1k(), items.networkTool(), materials.fluixCrystal(), materials.certusQuartzCrystal() ); } - private ItemStack findFirst( AEItemDefinition... choices ) + private ItemStack findFirst( IItemDefinition... choices ) { - for ( AEItemDefinition a : choices ) + for ( IItemDefinition definition : choices ) { - if ( a != null ) + for ( ItemStack definitionStack : definition.maybeStack( 1 ).asSet() ) { - ItemStack is = a.stack( 1 ); - if ( is != null ) - { - return is; - } + return definitionStack; } } diff --git a/src/main/java/appeng/core/CreativeTabFacade.java b/src/main/java/appeng/core/CreativeTabFacade.java index cdba98345..031bf5d43 100644 --- a/src/main/java/appeng/core/CreativeTabFacade.java +++ b/src/main/java/appeng/core/CreativeTabFacade.java @@ -19,9 +19,12 @@ package appeng.core; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import com.google.common.base.Optional; + import appeng.api.AEApi; import appeng.items.parts.ItemFacade; @@ -43,7 +46,13 @@ public final class CreativeTabFacade extends CreativeTabs @Override public ItemStack getIconItemStack() { - return ((ItemFacade) AEApi.instance().items().itemFacade.item()).getCreativeTabIcon(); + final Optional maybeFacade = AEApi.instance().definitions().items().facade().maybeItem(); + if ( maybeFacade.isPresent() ) + { + return ((ItemFacade) maybeFacade.get()).getCreativeTabIcon(); + } + + return new ItemStack( Blocks.planks ); } public static void init() diff --git a/src/main/java/appeng/core/FeatureHandlerRegistry.java b/src/main/java/appeng/core/FeatureHandlerRegistry.java new file mode 100644 index 000000000..ec35fde37 --- /dev/null +++ b/src/main/java/appeng/core/FeatureHandlerRegistry.java @@ -0,0 +1,41 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.core; + + +import java.util.HashSet; +import java.util.Set; + +import appeng.core.features.IFeatureHandler; + + +public final class FeatureHandlerRegistry +{ + private final Set registry = new HashSet(); + + public void addFeatureHandler( IFeatureHandler feature ) + { + this.registry.add( feature ); + } + + public Set getRegisteredFeatureHandlers() + { + return this.registry; + } +} diff --git a/src/main/java/appeng/core/FeatureRegistry.java b/src/main/java/appeng/core/FeatureRegistry.java new file mode 100644 index 000000000..74848f59f --- /dev/null +++ b/src/main/java/appeng/core/FeatureRegistry.java @@ -0,0 +1,41 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.core; + + +import java.util.HashSet; +import java.util.Set; + +import appeng.core.features.IAEFeature; + + +public final class FeatureRegistry +{ + private final Set registry = new HashSet(); + + public void addFeature( IAEFeature feature ) + { + this.registry.add( feature ); + } + + public Set getRegisteredFeatures() + { + return this.registry; + } +} diff --git a/src/main/java/appeng/core/Registration.java b/src/main/java/appeng/core/Registration.java index 109251f62..2ac4e7667 100644 --- a/src/main/java/appeng/core/Registration.java +++ b/src/main/java/appeng/core/Registration.java @@ -19,8 +19,9 @@ package appeng.core; -import java.lang.reflect.Field; - +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.util.WeightedRandomChestContent; import net.minecraft.world.biome.BiomeGenBase; @@ -37,14 +38,15 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; -import com.google.common.base.Optional; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; - import appeng.api.AEApi; import appeng.api.IAppEngApi; import appeng.api.config.Upgrades; import appeng.api.definitions.Blocks; +import appeng.api.definitions.IBlocks; +import appeng.api.definitions.IDefinitions; +import appeng.api.definitions.IItems; +import appeng.api.definitions.IMaterials; +import appeng.api.definitions.IParts; import appeng.api.definitions.Items; import appeng.api.definitions.Materials; import appeng.api.definitions.Parts; @@ -62,116 +64,23 @@ import appeng.api.networking.spatial.ISpatialCache; import appeng.api.networking.storage.IStorageGrid; import appeng.api.networking.ticking.ITickManager; import appeng.api.parts.IPartHelper; -import appeng.api.util.AEColor; -import appeng.api.util.AEItemDefinition; -import appeng.block.crafting.BlockCraftingMonitor; -import appeng.block.crafting.BlockCraftingStorage; -import appeng.block.crafting.BlockCraftingUnit; -import appeng.block.crafting.BlockMolecularAssembler; -import appeng.block.grindstone.BlockCrank; -import appeng.block.grindstone.BlockGrinder; -import appeng.block.misc.BlockCellWorkbench; -import appeng.block.misc.BlockCharger; -import appeng.block.misc.BlockCondenser; -import appeng.block.misc.BlockInscriber; -import appeng.block.misc.BlockInterface; -import appeng.block.misc.BlockLightDetector; -import appeng.block.misc.BlockPaint; -import appeng.block.misc.BlockQuartzGrowthAccelerator; -import appeng.block.misc.BlockQuartzTorch; -import appeng.block.misc.BlockSecurity; -import appeng.block.misc.BlockSkyCompass; -import appeng.block.misc.BlockTinyTNT; -import appeng.block.misc.BlockVibrationChamber; import appeng.block.networking.BlockCableBus; -import appeng.block.networking.BlockController; -import appeng.block.networking.BlockCreativeEnergyCell; -import appeng.block.networking.BlockDenseEnergyCell; -import appeng.block.networking.BlockEnergyAcceptor; -import appeng.block.networking.BlockEnergyCell; -import appeng.block.networking.BlockWireless; -import appeng.block.qnb.BlockQuantumLinkChamber; -import appeng.block.qnb.BlockQuantumRing; -import appeng.block.solids.BlockFluix; -import appeng.block.solids.BlockQuartz; -import appeng.block.solids.BlockQuartzChiseled; -import appeng.block.solids.BlockQuartzGlass; -import appeng.block.solids.BlockQuartzLamp; -import appeng.block.solids.BlockQuartzPillar; -import appeng.block.solids.BlockSkyStone; -import appeng.block.solids.OreQuartz; -import appeng.block.solids.OreQuartzCharged; -import appeng.block.spatial.BlockMatrixFrame; -import appeng.block.spatial.BlockSpatialIOPort; -import appeng.block.spatial.BlockSpatialPylon; -import appeng.block.stair.ChiseledQuartzStairBlock; -import appeng.block.stair.FluixStairBlock; -import appeng.block.stair.QuartzPillarStairBlock; -import appeng.block.stair.QuartzStairBlock; -import appeng.block.stair.SkyStoneBlockStairBlock; -import appeng.block.stair.SkyStoneBrickStairBlock; -import appeng.block.stair.SkyStoneSmallBrickStairBlock; -import appeng.block.stair.SkyStoneStairBlock; -import appeng.block.storage.BlockChest; -import appeng.block.storage.BlockDrive; -import appeng.block.storage.BlockIOPort; -import appeng.block.storage.BlockSkyChest; import appeng.core.features.AEFeature; -import appeng.core.features.ColoredItemDefinition; -import appeng.core.features.DamagedItemDefinition; +import appeng.core.features.DefinitionConverter; import appeng.core.features.IAEFeature; import appeng.core.features.IFeatureHandler; -import appeng.core.features.IStackSrc; -import appeng.core.features.ItemStackSrc; -import appeng.core.features.NullItemDefinition; -import appeng.core.features.WrappedDamageItemDefinition; import appeng.core.features.registries.P2PTunnelRegistry; import appeng.core.features.registries.entries.BasicCellHandler; import appeng.core.features.registries.entries.CreativeCellHandler; import appeng.core.localization.GuiText; import appeng.core.localization.PlayerMessages; import appeng.core.stats.PlayerStatsRegistration; -import appeng.debug.BlockChunkloader; -import appeng.debug.BlockCubeGenerator; -import appeng.debug.BlockItemGen; -import appeng.debug.BlockPhantomNode; -import appeng.debug.ToolDebugCard; -import appeng.debug.ToolEraser; -import appeng.debug.ToolMeteoritePlacer; -import appeng.debug.ToolReplicatorCard; import appeng.hooks.AETrading; -import appeng.hooks.MeteoriteWorldGen; -import appeng.hooks.QuartzWorldGen; +import appeng.worldgen.MeteoriteWorldGen; +import appeng.worldgen.QuartzWorldGen; import appeng.hooks.TickHandler; import appeng.integration.IntegrationType; import appeng.items.materials.ItemMultiMaterial; -import appeng.items.materials.MaterialType; -import appeng.items.misc.ItemCrystalSeed; -import appeng.items.misc.ItemEncodedPattern; -import appeng.items.misc.ItemPaintBall; -import appeng.items.parts.ItemFacade; -import appeng.items.parts.ItemMultiPart; -import appeng.items.parts.PartType; -import appeng.items.storage.ItemBasicStorageCell; -import appeng.items.storage.ItemCreativeStorageCell; -import appeng.items.storage.ItemSpatialStorageCell; -import appeng.items.storage.ItemViewCell; -import appeng.items.tools.ToolBiometricCard; -import appeng.items.tools.ToolMemoryCard; -import appeng.items.tools.ToolNetworkTool; -import appeng.items.tools.powered.ToolChargedStaff; -import appeng.items.tools.powered.ToolColorApplicator; -import appeng.items.tools.powered.ToolEntropyManipulator; -import appeng.items.tools.powered.ToolMassCannon; -import appeng.items.tools.powered.ToolPortableCell; -import appeng.items.tools.powered.ToolWirelessTerminal; -import appeng.items.tools.quartz.ToolQuartzAxe; -import appeng.items.tools.quartz.ToolQuartzCuttingKnife; -import appeng.items.tools.quartz.ToolQuartzHoe; -import appeng.items.tools.quartz.ToolQuartzPickaxe; -import appeng.items.tools.quartz.ToolQuartzSpade; -import appeng.items.tools.quartz.ToolQuartzSword; -import appeng.items.tools.quartz.ToolQuartzWrench; import appeng.me.cache.CraftingGridCache; import appeng.me.cache.EnergyGridCache; import appeng.me.cache.GridStorageCache; @@ -207,7 +116,6 @@ import appeng.recipes.ores.OreDictionaryHandler; import appeng.spatial.BiomeGenStorage; import appeng.spatial.StorageWorldProvider; import appeng.tile.AEBaseTile; -import appeng.util.ClassInstantiation; import appeng.util.Platform; @@ -216,37 +124,22 @@ public final class Registration final public static Registration INSTANCE = new Registration(); private final RecipeHandler recipeHandler; - private final Multimap> featuresToEntities; + private final DefinitionConverter converter; public BiomeGenBase storageBiome; private Registration() { + this.converter = new DefinitionConverter(); this.recipeHandler = new RecipeHandler(); - this.featuresToEntities = ArrayListMultimap.create(); } public void preInitialize( FMLPreInitializationEvent event ) { this.registerSpatial( false ); - IRecipeHandlerRegistry recipeRegistry = AEApi.instance().registries().recipes(); - recipeRegistry.addNewSubItemResolver( new AEItemResolver() ); - - recipeRegistry.addNewCraftHandler( "hccrusher", HCCrusher.class ); - recipeRegistry.addNewCraftHandler( "mekcrusher", MekCrusher.class ); - recipeRegistry.addNewCraftHandler( "mekechamber", MekEnrichment.class ); - recipeRegistry.addNewCraftHandler( "grind", Grind.class ); - recipeRegistry.addNewCraftHandler( "crusher", Crusher.class ); - recipeRegistry.addNewCraftHandler( "grindfz", GrindFZ.class ); - recipeRegistry.addNewCraftHandler( "pulverizer", Pulverizer.class ); - recipeRegistry.addNewCraftHandler( "macerator", Macerator.class ); - - recipeRegistry.addNewCraftHandler( "smelt", Smelt.class ); - recipeRegistry.addNewCraftHandler( "inscribe", Inscribe.class ); - recipeRegistry.addNewCraftHandler( "press", Press.class ); - - recipeRegistry.addNewCraftHandler( "shaped", Shaped.class ); - recipeRegistry.addNewCraftHandler( "shapeless", Shapeless.class ); + final Api api = Api.INSTANCE; + IRecipeHandlerRegistry recipeRegistry = api.registries().recipes(); + this.registerCraftHandlers( recipeRegistry ); RecipeSorter.register( "AE2-Facade", FacadeRecipe.class, Category.SHAPED, "" ); RecipeSorter.register( "AE2-Shaped", ShapedRecipe.class, Category.SHAPED, "" ); @@ -254,219 +147,33 @@ public final class Registration MinecraftForge.EVENT_BUS.register( OreDictionaryHandler.INSTANCE ); - Items items = Api.INSTANCE.items(); - Materials materials = Api.INSTANCE.materials(); - Parts parts = Api.INSTANCE.parts(); - Blocks blocks = Api.INSTANCE.blocks(); + final ApiDefinitions definitions = api.definitions(); - AEItemDefinition materialItem = this.addFeature( ItemMultiMaterial.class ); + final IBlocks apiBlocks = definitions.blocks(); + final IItems apiItems = definitions.items(); + final IMaterials apiMaterials = definitions.materials(); + final IParts apiParts = definitions.parts(); - Class materialClass = materials.getClass(); - for ( MaterialType mat : MaterialType.values() ) + final Items items = api.items(); + final Materials materials = api.materials(); + final Parts parts = api.parts(); + final Blocks blocks = api.blocks(); + + this.assignMaterials( materials, apiMaterials ); + this.assignParts( parts, apiParts ); + this.assignBlocks( blocks, apiBlocks ); + this.assignItems( items, apiItems ); + + // Register all detected handlers and features (items, blocks) in pre-init + for ( IFeatureHandler handler : definitions.getFeatureHandlerRegistry().getRegisteredFeatureHandlers() ) { - try - { - if ( mat == MaterialType.InvalidType ) - ( ( ItemMultiMaterial ) materialItem.item() ).createMaterial( mat ); - else - { - Field f = materialClass.getField( "material" + mat.name() ); - IStackSrc is = ( ( ItemMultiMaterial ) materialItem.item() ).createMaterial( mat ); - if ( is != null ) - f.set( materials, new DamagedItemDefinition( is ) ); - else - f.set( materials, new NullItemDefinition() ); - } - } - catch ( Throwable err ) - { - AELog.severe( "Error creating material: " + mat.name() ); - throw new RuntimeException( err ); - } + handler.register(); } - AEItemDefinition partItem = this.addFeature( ItemMultiPart.class ); - - Class partClass = parts.getClass(); - for ( PartType type : PartType.values() ) + for ( IAEFeature feature : definitions.getFeatureRegistry().getRegisteredFeatures() ) { - try - { - if ( type == PartType.InvalidType ) - ( ( ItemMultiPart ) partItem.item() ).createPart( type, null ); - else - { - Field f = partClass.getField( "part" + type.name() ); - Enum[] variants = type.getVariants(); - if ( variants == null ) - { - ItemStackSrc is = ( ( ItemMultiPart ) partItem.item() ).createPart( type, null ); - if ( is != null ) - f.set( parts, new DamagedItemDefinition( is ) ); - else - f.set( parts, new NullItemDefinition() ); - } - else - { - if ( variants[0] instanceof AEColor ) - { - ColoredItemDefinition def = new ColoredItemDefinition(); - - for ( Enum v : variants ) - { - ItemStackSrc is = ( ( ItemMultiPart ) partItem.item() ).createPart( type, v ); - if ( is != null ) - def.add( ( AEColor ) v, is ); - } - - f.set( parts, def ); - } - } - } - } - catch ( Throwable err ) - { - AELog.severe( "Error creating part: " + type.name() ); - throw new RuntimeException( err ); - } + feature.postInit(); } - - // very important block! - blocks.blockMultiPart = this.addFeature( BlockCableBus.class ); - - blocks.blockCraftingUnit = this.addFeature( BlockCraftingUnit.class ); - blocks.blockCraftingAccelerator = new WrappedDamageItemDefinition( blocks.blockCraftingUnit, 1 ); - blocks.blockCraftingMonitor = this.addFeature( BlockCraftingMonitor.class ); - blocks.blockCraftingStorage1k = this.addFeature( BlockCraftingStorage.class ); - blocks.blockCraftingStorage4k = new WrappedDamageItemDefinition( blocks.blockCraftingStorage1k, 1 ); - blocks.blockCraftingStorage16k = new WrappedDamageItemDefinition( blocks.blockCraftingStorage1k, 2 ); - blocks.blockCraftingStorage64k = new WrappedDamageItemDefinition( blocks.blockCraftingStorage1k, 3 ); - blocks.blockMolecularAssembler = this.addFeature( BlockMolecularAssembler.class ); - - blocks.blockQuartzOre = this.addFeature( OreQuartz.class ); - blocks.blockQuartzOreCharged = this.addFeature( OreQuartzCharged.class ); - blocks.blockMatrixFrame = this.addFeature( BlockMatrixFrame.class ); - blocks.blockQuartz = this.addFeature( BlockQuartz.class ); - blocks.blockFluix = this.addFeature( BlockFluix.class ); - blocks.blockSkyStone = this.addFeature( BlockSkyStone.class ); - blocks.blockSkyChest = this.addFeature( BlockSkyChest.class ); - blocks.blockSkyCompass = this.addFeature( BlockSkyCompass.class ); - - blocks.blockQuartzGlass = this.addFeature( BlockQuartzGlass.class ); - blocks.blockQuartzVibrantGlass = this.addFeature( BlockQuartzLamp.class ); - blocks.blockQuartzPillar = this.addFeature( BlockQuartzPillar.class ); - blocks.blockQuartzChiseled = this.addFeature( BlockQuartzChiseled.class ); - blocks.blockQuartzTorch = this.addFeature( BlockQuartzTorch.class ); - blocks.blockLightDetector = this.addFeature( BlockLightDetector.class ); - blocks.blockCharger = this.addFeature( BlockCharger.class ); - blocks.blockQuartzGrowthAccelerator = this.addFeature( BlockQuartzGrowthAccelerator.class ); - - blocks.blockGrindStone = this.addFeature( BlockGrinder.class ); - blocks.blockCrankHandle = this.addFeature( BlockCrank.class ); - blocks.blockInscriber = this.addFeature( BlockInscriber.class ); - blocks.blockWireless = this.addFeature( BlockWireless.class ); - blocks.blockTinyTNT = this.addFeature( BlockTinyTNT.class ); - - blocks.blockQuantumRing = this.addFeature( BlockQuantumRing.class ); - blocks.blockQuantumLink = this.addFeature( BlockQuantumLinkChamber.class ); - - blocks.blockSpatialPylon = this.addFeature( BlockSpatialPylon.class ); - blocks.blockSpatialIOPort = this.addFeature( BlockSpatialIOPort.class ); - - blocks.blockController = this.addFeature( BlockController.class ); - blocks.blockDrive = this.addFeature( BlockDrive.class ); - blocks.blockChest = this.addFeature( BlockChest.class ); - blocks.blockInterface = this.addFeature( BlockInterface.class ); - blocks.blockCellWorkbench = this.addFeature( BlockCellWorkbench.class ); - blocks.blockIOPort = this.addFeature( BlockIOPort.class ); - blocks.blockCondenser = this.addFeature( BlockCondenser.class ); - blocks.blockEnergyAcceptor = this.addFeature( BlockEnergyAcceptor.class ); - blocks.blockVibrationChamber = this.addFeature( BlockVibrationChamber.class ); - - blocks.blockEnergyCell = this.addFeature( BlockEnergyCell.class ); - blocks.blockEnergyCellDense = this.addFeature( BlockDenseEnergyCell.class ); - blocks.blockEnergyCellCreative = this.addFeature( BlockCreativeEnergyCell.class ); - - blocks.blockSecurity = this.addFeature( BlockSecurity.class ); - blocks.blockPaint = this.addFeature( BlockPaint.class ); - - items.itemCellCreative = this.addFeature( ItemCreativeStorageCell.class ); - items.itemViewCell = this.addFeature( ItemViewCell.class ); - items.itemEncodedPattern = this.addFeature( ItemEncodedPattern.class ); - - items.itemCell1k = this.addFeature( ItemBasicStorageCell.class, MaterialType.Cell1kPart, 1 ); - items.itemCell4k = this.addFeature( ItemBasicStorageCell.class, MaterialType.Cell4kPart, 4 ); - items.itemCell16k = this.addFeature( ItemBasicStorageCell.class, MaterialType.Cell16kPart, 16 ); - items.itemCell64k = this.addFeature( ItemBasicStorageCell.class, MaterialType.Cell64kPart, 64 ); - - items.itemSpatialCell2 = this.addFeature( ItemSpatialStorageCell.class, MaterialType.Cell2SpatialPart, 2 ); - items.itemSpatialCell16 = this.addFeature( ItemSpatialStorageCell.class, MaterialType.Cell16SpatialPart, 16 ); - items.itemSpatialCell128 = this.addFeature( ItemSpatialStorageCell.class, MaterialType.Cell128SpatialPart, 128 ); - - items.itemCertusQuartzKnife = this.addFeature( ToolQuartzCuttingKnife.class, AEFeature.CertusQuartzTools ); - items.itemCertusQuartzWrench = this.addFeature( ToolQuartzWrench.class, AEFeature.CertusQuartzTools ); - items.itemCertusQuartzAxe = this.addFeature( ToolQuartzAxe.class, AEFeature.CertusQuartzTools ); - items.itemCertusQuartzHoe = this.addFeature( ToolQuartzHoe.class, AEFeature.CertusQuartzTools ); - items.itemCertusQuartzPick = this.addFeature( ToolQuartzPickaxe.class, AEFeature.CertusQuartzTools ); - items.itemCertusQuartzShovel = this.addFeature( ToolQuartzSpade.class, AEFeature.CertusQuartzTools ); - items.itemCertusQuartzSword = this.addFeature( ToolQuartzSword.class, AEFeature.CertusQuartzTools ); - - items.itemNetherQuartzKnife = this.addFeature( ToolQuartzCuttingKnife.class, AEFeature.NetherQuartzTools ); - items.itemNetherQuartzWrench = this.addFeature( ToolQuartzWrench.class, AEFeature.NetherQuartzTools ); - items.itemNetherQuartzAxe = this.addFeature( ToolQuartzAxe.class, AEFeature.NetherQuartzTools ); - items.itemNetherQuartzHoe = this.addFeature( ToolQuartzHoe.class, AEFeature.NetherQuartzTools ); - items.itemNetherQuartzPick = this.addFeature( ToolQuartzPickaxe.class, AEFeature.NetherQuartzTools ); - items.itemNetherQuartzShovel = this.addFeature( ToolQuartzSpade.class, AEFeature.NetherQuartzTools ); - items.itemNetherQuartzSword = this.addFeature( ToolQuartzSword.class, AEFeature.NetherQuartzTools ); - - items.itemMassCannon = this.addFeature( ToolMassCannon.class ); - items.itemMemoryCard = this.addFeature( ToolMemoryCard.class ); - items.itemChargedStaff = this.addFeature( ToolChargedStaff.class ); - items.itemEntropyManipulator = this.addFeature( ToolEntropyManipulator.class ); - items.itemColorApplicator = this.addFeature( ToolColorApplicator.class ); - - items.itemWirelessTerminal = this.addFeature( ToolWirelessTerminal.class ); - items.itemNetworkTool = this.addFeature( ToolNetworkTool.class ); - items.itemPortableCell = this.addFeature( ToolPortableCell.class ); - items.itemBiometricCard = this.addFeature( ToolBiometricCard.class ); - - items.itemFacade = this.addFeature( ItemFacade.class ); - items.itemCrystalSeed = this.addFeature( ItemCrystalSeed.class ); - - ColoredItemDefinition paintBall; - ColoredItemDefinition lumenPaintBall; - items.itemPaintBall = paintBall = new ColoredItemDefinition(); - items.itemLumenPaintBall = lumenPaintBall = new ColoredItemDefinition(); - AEItemDefinition pb = this.addFeature( ItemPaintBall.class ); - - for ( AEColor c : AEColor.values() ) - { - if ( c != AEColor.Transparent ) - { - paintBall.add( c, new ItemStackSrc( pb.item(), c.ordinal() ) ); - lumenPaintBall.add( c, new ItemStackSrc( pb.item(), 20 + c.ordinal() ) ); - } - } - - // stairs - this.addFeature( SkyStoneStairBlock.class, blocks.blockSkyStone.block(), 0 ); - this.addFeature( SkyStoneBlockStairBlock.class, blocks.blockSkyStone.block(), 1 ); - this.addFeature( SkyStoneBrickStairBlock.class, blocks.blockSkyStone.block(), 2 ); - this.addFeature( SkyStoneSmallBrickStairBlock.class, blocks.blockSkyStone.block(), 3 ); - this.addFeature( FluixStairBlock.class, blocks.blockFluix.block() ); - this.addFeature( QuartzStairBlock.class, blocks.blockQuartz.block() ); - this.addFeature( ChiseledQuartzStairBlock.class, blocks.blockQuartzChiseled.block() ); - this.addFeature( QuartzPillarStairBlock.class, blocks.blockQuartzPillar.block() ); - - // unsupported developer tools - this.addFeature( ToolEraser.class ); - this.addFeature( ToolMeteoritePlacer.class ); - this.addFeature( ToolDebugCard.class ); - this.addFeature( ToolReplicatorCard.class ); - this.addFeature( BlockItemGen.class ); - this.addFeature( BlockChunkloader.class ); - this.addFeature( BlockPhantomNode.class ); - this.addFeature( BlockCubeGenerator.class ); } private void registerSpatial( boolean force ) @@ -508,40 +215,296 @@ public final class Registration } } - private AEItemDefinition addFeature( Class featureClass, Object... args ) + private void registerCraftHandlers( IRecipeHandlerRegistry registry ) { - final ClassInstantiation instantiation = new ClassInstantiation( featureClass, args ); - final Optional instance = instantiation.get(); + registry.addNewSubItemResolver( new AEItemResolver() ); - if ( instance.isPresent() ) - { - final IAEFeature feature = instance.get(); - final IFeatureHandler handler = feature.handler(); - if ( handler.isFeatureAvailable() ) - { - for ( AEFeature f : handler.getFeatures() ) - { - this.featuresToEntities.put( f, featureClass ); - } + registry.addNewCraftHandler( "hccrusher", HCCrusher.class ); + registry.addNewCraftHandler( "mekcrusher", MekCrusher.class ); + registry.addNewCraftHandler( "mekechamber", MekEnrichment.class ); + registry.addNewCraftHandler( "grind", Grind.class ); + registry.addNewCraftHandler( "crusher", Crusher.class ); + registry.addNewCraftHandler( "grindfz", GrindFZ.class ); + registry.addNewCraftHandler( "pulverizer", Pulverizer.class ); + registry.addNewCraftHandler( "macerator", Macerator.class ); - handler.register(); - feature.postInit(); + registry.addNewCraftHandler( "smelt", Smelt.class ); + registry.addNewCraftHandler( "inscribe", Inscribe.class ); + registry.addNewCraftHandler( "press", Press.class ); - return handler.getDefinition(); - } - else - { - return null; - } - } - else - { - throw new RuntimeException( "Error upon Class Instantiation with Feature: " + featureClass.getName() ); - } + registry.addNewCraftHandler( "shaped", Shaped.class ); + registry.addNewCraftHandler( "shapeless", Shapeless.class ); + } + + /** + * Assigns materials from the new API to the old API + * + * Uses direct cast, since its only a temporary solution anyways + * + * @param target old API + * @param source new API + * + * @deprecated to be removed when the public definition API is removed + */ + @Deprecated + private void assignMaterials( Materials target, IMaterials source ) + { + target.materialCell2SpatialPart = this.converter.of( source.cell2SpatialPart() ); + target.materialCell16SpatialPart = this.converter.of( source.cell16SpatialPart() ); + target.materialCell128SpatialPart = this.converter.of( source.cell128SpatialPart() ); + + target.materialSilicon = this.converter.of( source.silicon() ); + target.materialSkyDust = this.converter.of( source.skyDust() ); + + target.materialCalcProcessorPress = this.converter.of( source.calcProcessorPress() ); + target.materialEngProcessorPress = this.converter.of( source.engProcessorPress() ); + target.materialLogicProcessorPress = this.converter.of( source.logicProcessorPress() ); + + target.materialCalcProcessorPrint = this.converter.of( source.calcProcessorPrint() ); + target.materialEngProcessorPrint = this.converter.of( source.engProcessorPrint() ); + target.materialLogicProcessorPrint = this.converter.of( source.logicProcessorPrint() ); + + target.materialSiliconPress = this.converter.of( source.siliconPress() ); + target.materialSiliconPrint = this.converter.of( source.siliconPrint() ); + + target.materialNamePress = this.converter.of( source.namePress() ); + + target.materialLogicProcessor = this.converter.of( source.logicProcessor() ); + target.materialCalcProcessor = this.converter.of( source.calcProcessor() ); + target.materialEngProcessor = this.converter.of( source.engProcessor() ); + + target.materialBasicCard = this.converter.of( source.basicCard() ); + target.materialAdvCard = this.converter.of( source.advCard() ); + + target.materialPurifiedCertusQuartzCrystal = this.converter.of( source.purifiedCertusQuartzCrystal() ); + target.materialPurifiedNetherQuartzCrystal = this.converter.of( source.purifiedNetherQuartzCrystal() ); + target.materialPurifiedFluixCrystal = this.converter.of( source.purifiedFluixCrystal() ); + + target.materialCell1kPart = this.converter.of( source.cell1kPart() ); + target.materialCell4kPart = this.converter.of( source.cell4kPart() ); + target.materialCell16kPart = this.converter.of( source.cell16kPart() ); + target.materialCell64kPart = this.converter.of( source.cell64kPart() ); + target.materialEmptyStorageCell = this.converter.of( source.emptyStorageCell() ); + + target.materialCardRedstone = this.converter.of( source.cardRedstone() ); + target.materialCardSpeed = this.converter.of( source.cardSpeed() ); + target.materialCardCapacity = this.converter.of( source.cardCapacity() ); + target.materialCardFuzzy = this.converter.of( source.cardFuzzy() ); + target.materialCardInverter = this.converter.of( source.cardInverter() ); + target.materialCardCrafting = this.converter.of( source.cardCrafting() ); + + target.materialEnderDust = this.converter.of( source.enderDust() ); + target.materialFlour = this.converter.of( source.flour() ); + target.materialGoldDust = this.converter.of( source.goldDust() ); + target.materialIronDust = this.converter.of( source.ironDust() ); + target.materialFluixDust = this.converter.of( source.fluixDust() ); + target.materialCertusQuartzDust = this.converter.of( source.certusQuartzDust() ); + target.materialNetherQuartzDust = this.converter.of( source.netherQuartzDust() ); + + target.materialMatterBall = this.converter.of( source.matterBall() ); + target.materialIronNugget = this.converter.of( source.ironNugget() ); + + target.materialCertusQuartzCrystal = this.converter.of( source.certusQuartzCrystal() ); + target.materialCertusQuartzCrystalCharged = this.converter.of( source.certusQuartzCrystalCharged() ); + target.materialFluixCrystal = this.converter.of( source.fluixCrystal() ); + target.materialFluixPearl = this.converter.of( source.fluixPearl() ); + + target.materialWoodenGear = this.converter.of( source.woodenGear() ); + + target.materialWireless = this.converter.of( source.wireless() ); + target.materialWirelessBooster = this.converter.of( source.wirelessBooster() ); + + target.materialAnnihilationCore = this.converter.of( source.annihilationCore() ); + target.materialFormationCore = this.converter.of( source.formationCore() ); + + target.materialSingularity = this.converter.of( source.singularity() ); + target.materialQESingularity = this.converter.of( source.qESingularity() ); + target.materialBlankPattern = this.converter.of( source.blankPattern() ); + } + + /** + * Assigns parts from the new API to the old API + * + * @param target old API + * @param source new API + * + * @deprecated to be removed when the public definition API is removed + */ + @Deprecated + private void assignParts( Parts target, IParts source ) + { + target.partCableSmart = source.cableSmart(); + target.partCableCovered = source.cableCovered(); + target.partCableGlass = source.cableGlass(); + target.partCableDense = source.cableDense(); + // target.partLumenCableSmart = source.lumenCableSmart(); + // target.partLumenCableCovered = source.lumenCableCovered(); + // target.partLumenCableGlass = source.lumenCableGlass(); + // target.partLumenCableDense = source.lumenCableDense(); + target.partQuartzFiber = this.converter.of( source.quartzFiber() ); + target.partToggleBus = this.converter.of( source.toggleBus() ); + target.partInvertedToggleBus = this.converter.of( source.invertedToggleBus() ); + target.partStorageBus = this.converter.of( source.storageBus() ); + target.partImportBus = this.converter.of( source.importBus() ); + target.partExportBus = this.converter.of( source.exportBus() ); + target.partInterface = this.converter.of( source.iface() ); + target.partLevelEmitter = this.converter.of( source.levelEmitter() ); + target.partAnnihilationPlane = this.converter.of( source.annihilationPlane() ); + target.partFormationPlane = this.converter.of( source.formationPlane() ); + + target.partCableAnchor = this.converter.of( source.cableAnchor() ); + target.partP2PTunnelLight = target.partCableAnchor; + target.partP2PTunnelRF = target.partP2PTunnelLight; + target.partP2PTunnelEU = target.partP2PTunnelRF; + target.partP2PTunnelLiquids = target.partP2PTunnelEU; + target.partP2PTunnelItems = target.partP2PTunnelLiquids; + target.partP2PTunnelRedstone = target.partP2PTunnelItems; + target.partP2PTunnelME = target.partP2PTunnelRedstone; + target.partMonitor = this.converter.of( source.monitor() ); + target.partSemiDarkMonitor = this.converter.of( source.semiDarkMonitor() ); + target.partDarkMonitor = this.converter.of( source.darkMonitor() ); + target.partInterfaceTerminal = this.converter.of( source.interfaceTerminal() ); + target.partPatternTerminal = this.converter.of( source.patternTerminal() ); + target.partCraftingTerminal = this.converter.of( source.craftingTerminal() ); + target.partTerminal = this.converter.of( source.terminal() ); + target.partStorageMonitor = this.converter.of( source.storageMonitor() ); + target.partConversionMonitor = this.converter.of( source.conversionMonitor() ); + } + + /** + * Assigns blocks from the new API to the old API + * + * @param target old API + * @param source new API + * + * @deprecated to be removed when the public definition API is removed + */ + @Deprecated + private void assignBlocks( Blocks target, IBlocks source ) + { + target.blockMultiPart = this.converter.of( source.multiPart() ); + + target.blockCraftingUnit = this.converter.of( source.craftingUnit() ); + target.blockCraftingAccelerator = this.converter.of( source.craftingAccelerator() ); + target.blockCraftingMonitor = this.converter.of( source.craftingMonitor() ); + target.blockCraftingStorage1k = this.converter.of( source.craftingStorage1k() ); + target.blockCraftingStorage4k = this.converter.of( source.craftingStorage4k() ); + target.blockCraftingStorage16k = this.converter.of( source.craftingStorage16k() ); + target.blockCraftingStorage64k = this.converter.of( source.craftingStorage64k() ); + target.blockMolecularAssembler = this.converter.of( source.molecularAssembler() ); + + target.blockQuartzOre = this.converter.of( source.quartzOre() ); + target.blockQuartzOreCharged = this.converter.of( source.quartzOreCharged() ); + target.blockMatrixFrame = this.converter.of( source.matrixFrame() ); + target.blockQuartz = this.converter.of( source.quartz() ); + target.blockFluix = this.converter.of( source.fluix() ); + target.blockSkyStone = this.converter.of( source.skyStone() ); + target.blockSkyChest = this.converter.of( source.skyChest() ); + target.blockSkyCompass = this.converter.of( source.skyCompass() ); + + target.blockQuartzGlass = this.converter.of( source.quartzGlass() ); + target.blockQuartzVibrantGlass = this.converter.of( source.quartzVibrantGlass() ); + target.blockQuartzPillar = this.converter.of( source.quartzPillar() ); + target.blockQuartzChiseled = this.converter.of( source.quartzChiseled() ); + target.blockQuartzTorch = this.converter.of( source.quartzTorch() ); + target.blockLightDetector = this.converter.of( source.lightDetector() ); + target.blockCharger = this.converter.of( source.charger() ); + target.blockQuartzGrowthAccelerator = this.converter.of( source.quartzGrowthAccelerator() ); + + target.blockGrindStone = this.converter.of( source.grindStone() ); + target.blockCrankHandle = this.converter.of( source.crankHandle() ); + target.blockInscriber = this.converter.of( source.inscriber() ); + target.blockWireless = this.converter.of( source.wireless() ); + target.blockTinyTNT = this.converter.of( source.tinyTNT() ); + + target.blockQuantumRing = this.converter.of( source.quantumRing() ); + target.blockQuantumLink = this.converter.of( source.quantumLink() ); + + target.blockSpatialPylon = this.converter.of( source.spatialPylon() ); + target.blockSpatialIOPort = this.converter.of( source.spatialIOPort() ); + + target.blockController = this.converter.of( source.controller() ); + target.blockDrive = this.converter.of( source.drive() ); + target.blockChest = this.converter.of( source.chest() ); + target.blockInterface = this.converter.of( source.iface() ); + target.blockCellWorkbench = this.converter.of( source.cellWorkbench() ); + target.blockIOPort = this.converter.of( source.iOPort() ); + target.blockCondenser = this.converter.of( source.condenser() ); + target.blockEnergyAcceptor = this.converter.of( source.energyAcceptor() ); + target.blockVibrationChamber = this.converter.of( source.vibrationChamber() ); + + target.blockEnergyCell = this.converter.of( source.energyCell() ); + target.blockEnergyCellDense = this.converter.of( source.energyCellDense() ); + target.blockEnergyCellCreative = this.converter.of( source.energyCellCreative() ); + + target.blockSecurity = this.converter.of( source.security() ); + target.blockPaint = this.converter.of( source.paint() ); + } + + /** + * Assigns materials from the new API to the old API + * + * @param target old API + * @param source new API + * + * @deprecated to be removed when the public definition API is removed + */ + @Deprecated + private void assignItems( Items target, IItems source ) + { + target.itemCellCreative = this.converter.of( source.cellCreative() ); + target.itemViewCell = this.converter.of( source.viewCell() ); + target.itemEncodedPattern = this.converter.of( source.encodedPattern() ); + + target.itemCell1k = this.converter.of( source.cell1k() ); + target.itemCell4k = this.converter.of( source.cell4k() ); + target.itemCell16k = this.converter.of( source.cell16k() ); + target.itemCell64k = this.converter.of( source.cell64k() ); + + target.itemSpatialCell2 = this.converter.of( source.spatialCell2() ); + target.itemSpatialCell16 = this.converter.of( source.spatialCell16() ); + target.itemSpatialCell128 = this.converter.of( source.spatialCell128() ); + + target.itemCertusQuartzKnife = this.converter.of( source.certusQuartzKnife() ); + target.itemCertusQuartzWrench = this.converter.of( source.certusQuartzWrench() ); + target.itemCertusQuartzAxe = this.converter.of( source.certusQuartzAxe() ); + target.itemCertusQuartzHoe = this.converter.of( source.certusQuartzHoe() ); + target.itemCertusQuartzPick = this.converter.of( source.certusQuartzPick() ); + target.itemCertusQuartzShovel = this.converter.of( source.certusQuartzShovel() ); + target.itemCertusQuartzSword = this.converter.of( source.certusQuartzSword() ); + + target.itemNetherQuartzKnife = this.converter.of( source.netherQuartzKnife() ); + target.itemNetherQuartzWrench = this.converter.of( source.netherQuartzWrench() ); + target.itemNetherQuartzAxe = this.converter.of( source.netherQuartzAxe() ); + target.itemNetherQuartzHoe = this.converter.of( source.netherQuartzHoe() ); + target.itemNetherQuartzPick = this.converter.of( source.netherQuartzPick() ); + target.itemNetherQuartzShovel = this.converter.of( source.netherQuartzShovel() ); + target.itemNetherQuartzSword = this.converter.of( source.netherQuartzSword() ); + + target.itemMassCannon = this.converter.of( source.massCannon() ); + target.itemMemoryCard = this.converter.of( source.memoryCard() ); + target.itemChargedStaff = this.converter.of( source.chargedStaff() ); + target.itemEntropyManipulator = this.converter.of( source.entropyManipulator() ); + target.itemColorApplicator = this.converter.of( source.colorApplicator() ); + + target.itemWirelessTerminal = this.converter.of( source.wirelessTerminal() ); + target.itemNetworkTool = this.converter.of( source.networkTool() ); + target.itemPortableCell = this.converter.of( source.portableCell() ); + target.itemBiometricCard = this.converter.of( source.biometricCard() ); + + target.itemFacade = this.converter.of( source.facade() ); + target.itemCrystalSeed = this.converter.of( source.crystalSeed() ); + + target.itemPaintBall = source.coloredPaintBall(); + target.itemLumenPaintBall = source.coloredLumenPaintBall(); } public void initialize( FMLInitializationEvent event ) { + final IAppEngApi api = AEApi.instance(); + final IPartHelper partHelper = api.partHelper(); + final IRegistryContainer registries = api.registries(); + // Perform ore camouflage! ItemMultiMaterial.instance.makeUnique(); @@ -550,19 +513,18 @@ public final class Registration else this.recipeHandler.parseRecipes( new JarLoader( "/assets/appliedenergistics2/recipes/" ), "index.recipe" ); - IPartHelper ph = AEApi.instance().partHelper(); - ph.registerNewLayer( "appeng.parts.layers.LayerISidedInventory", "net.minecraft.inventory.ISidedInventory" ); - ph.registerNewLayer( "appeng.parts.layers.LayerIFluidHandler", "net.minecraftforge.fluids.IFluidHandler" ); - ph.registerNewLayer( "appeng.parts.layers.LayerITileStorageMonitorable", "appeng.api.implementations.tiles.ITileStorageMonitorable" ); + partHelper.registerNewLayer( "appeng.parts.layers.LayerISidedInventory", "net.minecraft.inventory.ISidedInventory" ); + partHelper.registerNewLayer( "appeng.parts.layers.LayerIFluidHandler", "net.minecraftforge.fluids.IFluidHandler" ); + partHelper.registerNewLayer( "appeng.parts.layers.LayerITileStorageMonitorable", "appeng.api.implementations.tiles.ITileStorageMonitorable" ); if ( AppEng.instance.isIntegrationEnabled( IntegrationType.IC2 ) ) { - ph.registerNewLayer( "appeng.parts.layers.LayerIEnergySink", "ic2.api.energy.tile.IEnergySink" ); - ph.registerNewLayer( "appeng.parts.layers.LayerIEnergySource", "ic2.api.energy.tile.IEnergySource" ); + partHelper.registerNewLayer( "appeng.parts.layers.LayerIEnergySink", "ic2.api.energy.tile.IEnergySink" ); + partHelper.registerNewLayer( "appeng.parts.layers.LayerIEnergySource", "ic2.api.energy.tile.IEnergySource" ); } if ( AppEng.instance.isIntegrationEnabled( IntegrationType.RF ) ) - ph.registerNewLayer( "appeng.parts.layers.LayerIEnergyHandler", "cofh.api.energy.IEnergyReceiver" ); + partHelper.registerNewLayer( "appeng.parts.layers.LayerIEnergyHandler", "cofh.api.energy.IEnergyReceiver" ); FMLCommonHandler.instance().bus().register( TickHandler.INSTANCE ); MinecraftForge.EVENT_BUS.register( TickHandler.INSTANCE ); @@ -571,7 +533,7 @@ public final class Registration MinecraftForge.EVENT_BUS.register( pp ); FMLCommonHandler.instance().bus().register( pp ); - IGridCacheRegistry gcr = AEApi.instance().registries().gridCache(); + IGridCacheRegistry gcr = registries.gridCache(); gcr.registerGridCache( ITickManager.class, TickManagerCache.class ); gcr.registerGridCache( IEnergyGrid.class, EnergyGridCache.class ); gcr.registerGridCache( IPathingGrid.class, PathGridCache.class ); @@ -581,12 +543,17 @@ public final class Registration gcr.registerGridCache( ISecurityGrid.class, SecurityCache.class ); gcr.registerGridCache( ICraftingGrid.class, CraftingGridCache.class ); - AEApi.instance().registries().externalStorage().addExternalStorageInterface( new AEExternalHandler() ); + registries.externalStorage().addExternalStorageInterface( new AEExternalHandler() ); - AEApi.instance().registries().cell().addCellHandler( new BasicCellHandler() ); - AEApi.instance().registries().cell().addCellHandler( new CreativeCellHandler() ); + registries.cell().addCellHandler( new BasicCellHandler() ); + registries.cell().addCellHandler( new CreativeCellHandler() ); - AEApi.instance().registries().matterCannon().registerAmmo( AEApi.instance().materials().materialMatterBall.stack( 1 ), 32.0 ); + for ( ItemStack ammoStack : api.definitions().materials().matterBall().maybeStack( 1 ).asSet() ) + { + final double weight = 32; + + registries.matterCannon().registerAmmo( ammoStack, weight ); + } this.recipeHandler.injectRecipes(); @@ -607,95 +574,108 @@ public final class Registration final IAppEngApi api = AEApi.instance(); final IRegistryContainer registries = api.registries(); - final Parts parts = api.parts(); - final Blocks blocks = api.blocks(); - final Items items = api.items(); + final IDefinitions definitions = api.definitions(); + final IParts parts = definitions.parts(); + final IBlocks blocks = definitions.blocks(); + final IItems items = definitions.items(); // default settings.. - ( ( P2PTunnelRegistry ) registries.p2pTunnel() ).configure(); + ( (P2PTunnelRegistry) registries.p2pTunnel() ).configure(); // add to localization.. PlayerMessages.values(); GuiText.values(); - Api.INSTANCE.partHelper.initFMPSupport(); - ( ( BlockCableBus ) blocks.blockMultiPart.block() ).setupTile(); + Api.INSTANCE.getPartHelper().initFMPSupport(); + for ( Block block : blocks.multiPart().maybeBlock().asSet() ) + { + ( (BlockCableBus) block ).setupTile(); + } // Interface - Upgrades.CRAFTING.registerItem( parts.partInterface, 1 ); - Upgrades.CRAFTING.registerItem( blocks.blockInterface, 1 ); + Upgrades.CRAFTING.registerItem( parts.iface(), 1 ); + Upgrades.CRAFTING.registerItem( blocks.iface(), 1 ); // IO Port! - Upgrades.SPEED.registerItem( blocks.blockIOPort, 3 ); - Upgrades.REDSTONE.registerItem( blocks.blockIOPort, 1 ); + Upgrades.SPEED.registerItem( blocks.iOPort(), 3 ); + Upgrades.REDSTONE.registerItem( blocks.iOPort(), 1 ); // Level Emitter! - Upgrades.FUZZY.registerItem( parts.partLevelEmitter, 1 ); - Upgrades.CRAFTING.registerItem( parts.partLevelEmitter, 1 ); + Upgrades.FUZZY.registerItem( parts.levelEmitter(), 1 ); + Upgrades.CRAFTING.registerItem( parts.levelEmitter(), 1 ); // Import Bus - Upgrades.FUZZY.registerItem( parts.partImportBus, 1 ); - Upgrades.REDSTONE.registerItem( parts.partImportBus, 1 ); - Upgrades.CAPACITY.registerItem( parts.partImportBus, 2 ); - Upgrades.SPEED.registerItem( parts.partImportBus, 4 ); + Upgrades.FUZZY.registerItem( parts.importBus(), 1 ); + Upgrades.REDSTONE.registerItem( parts.importBus(), 1 ); + Upgrades.CAPACITY.registerItem( parts.importBus(), 2 ); + Upgrades.SPEED.registerItem( parts.importBus(), 4 ); // Export Bus - Upgrades.FUZZY.registerItem( parts.partExportBus, 1 ); - Upgrades.REDSTONE.registerItem( parts.partExportBus, 1 ); - Upgrades.CAPACITY.registerItem( parts.partExportBus, 2 ); - Upgrades.SPEED.registerItem( parts.partExportBus, 4 ); - Upgrades.CRAFTING.registerItem( parts.partExportBus, 1 ); + Upgrades.FUZZY.registerItem( parts.exportBus(), 1 ); + Upgrades.REDSTONE.registerItem( parts.exportBus(), 1 ); + Upgrades.CAPACITY.registerItem( parts.exportBus(), 2 ); + Upgrades.SPEED.registerItem( parts.exportBus(), 4 ); + Upgrades.CRAFTING.registerItem( parts.exportBus(), 1 ); // Storage Cells - Upgrades.FUZZY.registerItem( items.itemCell1k, 1 ); - Upgrades.INVERTER.registerItem( items.itemCell1k, 1 ); + Upgrades.FUZZY.registerItem( items.cell1k(), 1 ); + Upgrades.INVERTER.registerItem( items.cell1k(), 1 ); - Upgrades.FUZZY.registerItem( items.itemCell4k, 1 ); - Upgrades.INVERTER.registerItem( items.itemCell4k, 1 ); + Upgrades.FUZZY.registerItem( items.cell4k(), 1 ); + Upgrades.INVERTER.registerItem( items.cell4k(), 1 ); - Upgrades.FUZZY.registerItem( items.itemCell16k, 1 ); - Upgrades.INVERTER.registerItem( items.itemCell16k, 1 ); + Upgrades.FUZZY.registerItem( items.cell16k(), 1 ); + Upgrades.INVERTER.registerItem( items.cell16k(), 1 ); - Upgrades.FUZZY.registerItem( items.itemCell64k, 1 ); - Upgrades.INVERTER.registerItem( items.itemCell64k, 1 ); + Upgrades.FUZZY.registerItem( items.cell64k(), 1 ); + Upgrades.INVERTER.registerItem( items.cell64k(), 1 ); - Upgrades.FUZZY.registerItem( items.itemPortableCell, 1 ); - Upgrades.INVERTER.registerItem( items.itemPortableCell, 1 ); + Upgrades.FUZZY.registerItem( items.portableCell(), 1 ); + Upgrades.INVERTER.registerItem( items.portableCell(), 1 ); - Upgrades.FUZZY.registerItem( items.itemViewCell, 1 ); - Upgrades.INVERTER.registerItem( items.itemViewCell, 1 ); + Upgrades.FUZZY.registerItem( items.viewCell(), 1 ); + Upgrades.INVERTER.registerItem( items.viewCell(), 1 ); // Storage Bus - Upgrades.FUZZY.registerItem( parts.partStorageBus, 1 ); - Upgrades.INVERTER.registerItem( parts.partStorageBus, 1 ); - Upgrades.CAPACITY.registerItem( parts.partStorageBus, 5 ); + Upgrades.FUZZY.registerItem( parts.storageBus(), 1 ); + Upgrades.INVERTER.registerItem( parts.storageBus(), 1 ); + Upgrades.CAPACITY.registerItem( parts.storageBus(), 5 ); // Formation Plane - Upgrades.FUZZY.registerItem( parts.partFormationPlane, 1 ); - Upgrades.INVERTER.registerItem( parts.partFormationPlane, 1 ); - Upgrades.CAPACITY.registerItem( parts.partFormationPlane, 5 ); + Upgrades.FUZZY.registerItem( parts.formationPlane(), 1 ); + Upgrades.INVERTER.registerItem( parts.formationPlane(), 1 ); + Upgrades.CAPACITY.registerItem( parts.formationPlane(), 5 ); // Matter Cannon - Upgrades.FUZZY.registerItem( items.itemMassCannon, 1 ); - Upgrades.INVERTER.registerItem( items.itemMassCannon, 1 ); - Upgrades.SPEED.registerItem( items.itemMassCannon, 4 ); + Upgrades.FUZZY.registerItem( items.massCannon(), 1 ); + Upgrades.INVERTER.registerItem( items.massCannon(), 1 ); + Upgrades.SPEED.registerItem( items.massCannon(), 4 ); // Molecular Assembler - Upgrades.SPEED.registerItem( blocks.blockMolecularAssembler, 5 ); + Upgrades.SPEED.registerItem( blocks.molecularAssembler(), 5 ); // Inscriber - Upgrades.SPEED.registerItem( blocks.blockInscriber, 3 ); + Upgrades.SPEED.registerItem( blocks.inscriber(), 3 ); - if ( items.itemWirelessTerminal != null ) + for ( Item wirelessTerminalItem : items.wirelessTerminal().maybeItem().asSet() ) { - registries.wireless().registerWirelessHandler( ( IWirelessTermHandler ) items.itemWirelessTerminal.item() ); + registries.wireless().registerWirelessHandler( (IWirelessTermHandler) wirelessTerminalItem ); } if ( AEConfig.instance.isFeatureEnabled( AEFeature.ChestLoot ) ) { ChestGenHooks d = ChestGenHooks.getInfo( ChestGenHooks.MINESHAFT_CORRIDOR ); - d.addItem( new WeightedRandomChestContent( api.materials().materialCertusQuartzCrystal.stack( 1 ), 1, 4, 2 ) ); - d.addItem( new WeightedRandomChestContent( api.materials().materialCertusQuartzDust.stack( 1 ), 1, 4, 2 ) ); + + final IMaterials materials = definitions.materials(); + + for ( ItemStack crystal : materials.certusQuartzCrystal().maybeStack( 1 ).asSet() ) + { + d.addItem( new WeightedRandomChestContent( crystal, 1, 4, 2 ) ); + } + for ( ItemStack dust : materials.certusQuartzDust().maybeStack( 1 ).asSet() ) + { + d.addItem( new WeightedRandomChestContent( dust, 1, 4, 2 ) ); + } } // add villager trading to black smiths for a few basic materials diff --git a/src/main/java/appeng/core/WorldSettings.java b/src/main/java/appeng/core/WorldSettings.java index 05f3df432..b484a1e73 100644 --- a/src/main/java/appeng/core/WorldSettings.java +++ b/src/main/java/appeng/core/WorldSettings.java @@ -92,7 +92,7 @@ public class WorldSettings extends Configuration } final ConfigCategory playerList = this.getCategory( "players" ); - this.mappings = new PlayerMappings( playerList, AELog.instance ); + this.mappings = new PlayerMappings( playerList, AELog.INSTANCE ); } public static WorldSettings getInstance() diff --git a/src/main/java/appeng/core/api/definitions/ApiBlocks.java b/src/main/java/appeng/core/api/definitions/ApiBlocks.java new file mode 100644 index 000000000..25c465d89 --- /dev/null +++ b/src/main/java/appeng/core/api/definitions/ApiBlocks.java @@ -0,0 +1,599 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.core.api.definitions; + + +import java.util.Set; + +import com.google.common.collect.ImmutableSet; + +import appeng.api.definitions.IBlockDefinition; +import appeng.api.definitions.IBlocks; +import appeng.api.definitions.ITileDefinition; +import appeng.api.util.IOrientableBlock; +import appeng.block.crafting.BlockCraftingMonitor; +import appeng.block.crafting.BlockCraftingStorage; +import appeng.block.crafting.BlockCraftingUnit; +import appeng.block.crafting.BlockMolecularAssembler; +import appeng.block.grindstone.BlockCrank; +import appeng.block.grindstone.BlockGrinder; +import appeng.block.misc.BlockCellWorkbench; +import appeng.block.misc.BlockCharger; +import appeng.block.misc.BlockCondenser; +import appeng.block.misc.BlockInscriber; +import appeng.block.misc.BlockInterface; +import appeng.block.misc.BlockLightDetector; +import appeng.block.misc.BlockPaint; +import appeng.block.misc.BlockQuartzGrowthAccelerator; +import appeng.block.misc.BlockQuartzTorch; +import appeng.block.misc.BlockSecurity; +import appeng.block.misc.BlockSkyCompass; +import appeng.block.misc.BlockTinyTNT; +import appeng.block.misc.BlockVibrationChamber; +import appeng.block.networking.BlockCableBus; +import appeng.block.networking.BlockController; +import appeng.block.networking.BlockCreativeEnergyCell; +import appeng.block.networking.BlockDenseEnergyCell; +import appeng.block.networking.BlockEnergyAcceptor; +import appeng.block.networking.BlockEnergyCell; +import appeng.block.networking.BlockWireless; +import appeng.block.qnb.BlockQuantumLinkChamber; +import appeng.block.qnb.BlockQuantumRing; +import appeng.block.solids.BlockFluix; +import appeng.block.solids.BlockQuartz; +import appeng.block.solids.BlockQuartzChiseled; +import appeng.block.solids.BlockQuartzGlass; +import appeng.block.solids.BlockQuartzLamp; +import appeng.block.solids.BlockQuartzPillar; +import appeng.block.solids.BlockSkyStone; +import appeng.block.solids.OreQuartz; +import appeng.block.solids.OreQuartzCharged; +import appeng.block.spatial.BlockMatrixFrame; +import appeng.block.spatial.BlockSpatialIOPort; +import appeng.block.spatial.BlockSpatialPylon; +import appeng.block.stair.ChiseledQuartzStairBlock; +import appeng.block.stair.FluixStairBlock; +import appeng.block.stair.QuartzPillarStairBlock; +import appeng.block.stair.QuartzStairBlock; +import appeng.block.stair.SkyStoneBlockStairBlock; +import appeng.block.stair.SkyStoneBrickStairBlock; +import appeng.block.stair.SkyStoneSmallBrickStairBlock; +import appeng.block.stair.SkyStoneStairBlock; +import appeng.block.storage.BlockChest; +import appeng.block.storage.BlockDrive; +import appeng.block.storage.BlockIOPort; +import appeng.block.storage.BlockSkyChest; +import appeng.core.features.WrappedDamageItemDefinition; +import appeng.debug.BlockChunkloader; +import appeng.debug.BlockCubeGenerator; +import appeng.debug.BlockItemGen; +import appeng.debug.BlockPhantomNode; + + +/** + * Internal implementation for the API blocks + */ +public final class ApiBlocks implements IBlocks +{ + private final IBlockDefinition quartzOre; + private final IBlockDefinition quartzOreCharged; + private final IBlockDefinition matrixFrame; + private final IBlockDefinition quartz; + private final IBlockDefinition quartzPillar; + private final IBlockDefinition quartzChiseled; + private final IBlockDefinition quartzGlass; + private final IBlockDefinition quartzVibrantGlass; + private final IBlockDefinition quartzTorch; + private final IBlockDefinition fluix; + private final IBlockDefinition skyStone; + private final IBlockDefinition skyChest; + private final IBlockDefinition skyCompass; + private final ITileDefinition grindStone; + private final ITileDefinition crankHandle; + private final ITileDefinition inscriber; + private final ITileDefinition wireless; + private final ITileDefinition charger; + private final ITileDefinition tinyTNT; + private final ITileDefinition security; + private final ITileDefinition quantumRing; + private final ITileDefinition quantumLink; + private final ITileDefinition spatialPylon; + private final ITileDefinition spatialIOPort; + private final ITileDefinition multiPart; + private final ITileDefinition controller; + private final ITileDefinition drive; + private final ITileDefinition chest; + private final ITileDefinition iface; + private final ITileDefinition cellWorkbench; + private final ITileDefinition iOPort; + private final ITileDefinition condenser; + private final ITileDefinition energyAcceptor; + private final ITileDefinition vibrationChamber; + private final ITileDefinition quartzGrowthAccelerator; + private final ITileDefinition energyCell; + private final ITileDefinition energyCellDense; + private final ITileDefinition energyCellCreative; + private final ITileDefinition craftingUnit; + private final ITileDefinition craftingAccelerator; + private final ITileDefinition craftingStorage1k; + private final ITileDefinition craftingStorage4k; + private final ITileDefinition craftingStorage16k; + private final ITileDefinition craftingStorage64k; + private final ITileDefinition craftingMonitor; + private final ITileDefinition molecularAssembler; + private final ITileDefinition lightDetector; + private final ITileDefinition paint; + private final IBlockDefinition skyStoneStair; + private final IBlockDefinition skyStoneBlockStair; + private final IBlockDefinition skyStoneBrickStair; + private final IBlockDefinition skyStoneSmallBrickStair; + private final IBlockDefinition fluixStair; + private final IBlockDefinition quartzStair; + private final IBlockDefinition chiseledQuartzStair; + private final IBlockDefinition quartzPillarStair; + + private final IBlockDefinition itemGen; + private final IBlockDefinition chunkLoader; + private final IBlockDefinition phantomNode; + private final IBlockDefinition cubeGenerator; + + private final Set orientables; + + public ApiBlocks( DefinitionConstructor constructor ) + { + final BlockLightDetector lightDetector = new BlockLightDetector(); + final BlockQuartzPillar quartzPillar = new BlockQuartzPillar(); + final BlockSkyStone skyStone = new BlockSkyStone(); + final BlockFluix fluixBlock = new BlockFluix(); + final BlockQuartzGrowthAccelerator cga = new BlockQuartzGrowthAccelerator(); + final BlockQuartzTorch quartzTorch = new BlockQuartzTorch(); + final BlockQuartz quartzBlock = new BlockQuartz(); + final BlockQuartzChiseled chiseldQuartz = new BlockQuartzChiseled(); + + this.orientables = ImmutableSet.of( lightDetector, quartzPillar, skyStone, cga, quartzTorch ); + + this.quartzOre = constructor.registerBlockDefinition( new OreQuartz() ); + this.quartzOreCharged = constructor.registerBlockDefinition( new OreQuartzCharged() ); + this.matrixFrame = constructor.registerBlockDefinition( new BlockMatrixFrame() ); + this.quartz = constructor.registerBlockDefinition( quartzBlock ); + this.quartzPillar = constructor.registerBlockDefinition( quartzPillar ); + this.quartzChiseled = constructor.registerBlockDefinition( chiseldQuartz ); + this.quartzGlass = constructor.registerBlockDefinition( new BlockQuartzGlass() ); + this.quartzVibrantGlass = constructor.registerBlockDefinition( new BlockQuartzLamp() ); + this.quartzTorch = constructor.registerBlockDefinition( quartzTorch ); + this.fluix = constructor.registerBlockDefinition( fluixBlock ); + this.skyStone = constructor.registerBlockDefinition( skyStone ); + this.skyChest = constructor.registerBlockDefinition( new BlockSkyChest() ); + this.skyCompass = constructor.registerBlockDefinition( new BlockSkyCompass() ); + this.grindStone = constructor.registerTileDefinition( new BlockGrinder() ); + this.crankHandle = constructor.registerTileDefinition( new BlockCrank() ); + this.inscriber = constructor.registerTileDefinition( new BlockInscriber() ); + this.wireless = constructor.registerTileDefinition( new BlockWireless() ); + this.charger = constructor.registerTileDefinition( new BlockCharger() ); + this.tinyTNT = constructor.registerTileDefinition( new BlockTinyTNT() ); + this.security = constructor.registerTileDefinition( new BlockSecurity() ); + this.quantumRing = constructor.registerTileDefinition( new BlockQuantumRing() ); + this.quantumLink = constructor.registerTileDefinition( new BlockQuantumLinkChamber() ); + this.spatialPylon = constructor.registerTileDefinition( new BlockSpatialPylon() ); + this.spatialIOPort = constructor.registerTileDefinition( new BlockSpatialIOPort() ); + this.multiPart = constructor.registerTileDefinition( new BlockCableBus() ); + this.controller = constructor.registerTileDefinition( new BlockController() ); + this.drive = constructor.registerTileDefinition( new BlockDrive() ); + this.chest = constructor.registerTileDefinition( new BlockChest() ); + this.iface = constructor.registerTileDefinition( new BlockInterface() ); + this.cellWorkbench = constructor.registerTileDefinition( new BlockCellWorkbench() ); + this.iOPort = constructor.registerTileDefinition( new BlockIOPort() ); + this.condenser = constructor.registerTileDefinition( new BlockCondenser() ); + this.energyAcceptor = constructor.registerTileDefinition( new BlockEnergyAcceptor() ); + this.vibrationChamber = constructor.registerTileDefinition( new BlockVibrationChamber() ); + this.quartzGrowthAccelerator = constructor.registerTileDefinition( cga ); + this.energyCell = constructor.registerTileDefinition( new BlockEnergyCell() ); + this.energyCellDense = constructor.registerTileDefinition( new BlockDenseEnergyCell() ); + this.energyCellCreative = constructor.registerTileDefinition( new BlockCreativeEnergyCell() ); + this.craftingUnit = constructor.registerTileDefinition( new BlockCraftingUnit() ); + this.craftingAccelerator = new WrappedDamageItemDefinition( this.craftingUnit, 1 ); + this.craftingStorage1k = constructor.registerTileDefinition( new BlockCraftingStorage() ); + this.craftingStorage4k = new WrappedDamageItemDefinition( this.craftingStorage1k, 1 ); + this.craftingStorage16k = new WrappedDamageItemDefinition( this.craftingStorage1k, 2 ); + this.craftingStorage64k = new WrappedDamageItemDefinition( this.craftingStorage1k, 3 ); + this.craftingMonitor = constructor.registerTileDefinition( new BlockCraftingMonitor() ); + this.molecularAssembler = constructor.registerTileDefinition( new BlockMolecularAssembler() ); + this.lightDetector = constructor.registerTileDefinition( lightDetector ); + this.paint = constructor.registerTileDefinition( new BlockPaint() ); + + this.skyStoneStair = constructor.registerBlockDefinition( new SkyStoneStairBlock( skyStone, 0 ) ); + this.skyStoneBlockStair = constructor.registerBlockDefinition( new SkyStoneBlockStairBlock( skyStone, 1 ) ); + this.skyStoneBrickStair = constructor.registerBlockDefinition( new SkyStoneBrickStairBlock( skyStone, 2 ) ); + this.skyStoneSmallBrickStair = constructor.registerBlockDefinition( new SkyStoneSmallBrickStairBlock( skyStone, 3 ) ); + + this.fluixStair = constructor.registerBlockDefinition( new FluixStairBlock( fluixBlock ) ); + + this.quartzStair = constructor.registerBlockDefinition( new QuartzStairBlock( quartzBlock ) ); + + this.chiseledQuartzStair = constructor.registerBlockDefinition( new ChiseledQuartzStairBlock( chiseldQuartz ) ); + + this.quartzPillarStair = constructor.registerBlockDefinition( new QuartzPillarStairBlock( quartzPillar ) ); + + this.itemGen = constructor.registerBlockDefinition( new BlockItemGen() ); + this.chunkLoader = constructor.registerBlockDefinition( new BlockChunkloader() ); + this.phantomNode = constructor.registerBlockDefinition( new BlockPhantomNode() ); + this.cubeGenerator = constructor.registerBlockDefinition( new BlockCubeGenerator() ); + } + + @Override + public IBlockDefinition quartzOre() + { + return this.quartzOre; + } + + @Override + public IBlockDefinition quartzOreCharged() + { + return this.quartzOreCharged; + } + + @Override + public IBlockDefinition matrixFrame() + { + return this.matrixFrame; + } + + @Override + public IBlockDefinition quartz() + { + return this.quartz; + } + + @Override + public IBlockDefinition quartzPillar() + { + return this.quartzPillar; + } + + @Override + public IBlockDefinition quartzChiseled() + { + return this.quartzChiseled; + } + + @Override + public IBlockDefinition quartzGlass() + { + return this.quartzGlass; + } + + @Override + public IBlockDefinition quartzVibrantGlass() + { + return this.quartzVibrantGlass; + } + + @Override + public IBlockDefinition quartzTorch() + { + return this.quartzTorch; + } + + @Override + public IBlockDefinition fluix() + { + return this.fluix; + } + + @Override + public IBlockDefinition skyStone() + { + return this.skyStone; + } + + @Override + public IBlockDefinition skyChest() + { + return this.skyChest; + } + + @Override + public IBlockDefinition skyCompass() + { + return this.skyCompass; + } + + @Override + public IBlockDefinition skyStoneStair() + { + return this.skyStoneStair; + } + + @Override + public IBlockDefinition skyStoneBlockStair() + { + return this.skyStoneBlockStair; + } + + @Override + public IBlockDefinition skyStoneBrickStair() + { + return this.skyStoneBrickStair; + } + + @Override + public IBlockDefinition skyStoneSmallBrickStair() + { + return this.skyStoneSmallBrickStair; + } + + @Override + public IBlockDefinition fluixStair() + { + return this.fluixStair; + } + + @Override + public IBlockDefinition quartzStair() + { + return this.quartzStair; + } + + @Override + public IBlockDefinition chiseledQuartzStair() + { + return this.chiseledQuartzStair; + } + + @Override + public IBlockDefinition quartzPillarStair() + { + return this.quartzPillarStair; + } + + @Override + public ITileDefinition grindStone() + { + return this.grindStone; + } + + @Override + public ITileDefinition crankHandle() + { + return this.crankHandle; + } + + @Override + public ITileDefinition inscriber() + { + return this.inscriber; + } + + @Override + public ITileDefinition wireless() + { + return this.wireless; + } + + @Override + public ITileDefinition charger() + { + return this.charger; + } + + @Override + public ITileDefinition tinyTNT() + { + return this.tinyTNT; + } + + @Override + public ITileDefinition security() + { + return this.security; + } + + @Override + public ITileDefinition quantumRing() + { + return this.quantumRing; + } + + @Override + public ITileDefinition quantumLink() + { + return this.quantumLink; + } + + @Override + public ITileDefinition spatialPylon() + { + return this.spatialPylon; + } + + @Override + public ITileDefinition spatialIOPort() + { + return this.spatialIOPort; + } + + @Override + public ITileDefinition multiPart() + { + return this.multiPart; + } + + @Override + public ITileDefinition controller() + { + return this.controller; + } + + @Override + public ITileDefinition drive() + { + return this.drive; + } + + @Override + public ITileDefinition chest() + { + return this.chest; + } + + @Override + public ITileDefinition iface() + { + return this.iface; + } + + @Override + public ITileDefinition cellWorkbench() + { + return this.cellWorkbench; + } + + @Override + public ITileDefinition iOPort() + { + return this.iOPort; + } + + @Override + public ITileDefinition condenser() + { + return this.condenser; + } + + @Override + public ITileDefinition energyAcceptor() + { + return this.energyAcceptor; + } + + @Override + public ITileDefinition vibrationChamber() + { + return this.vibrationChamber; + } + + @Override + public ITileDefinition quartzGrowthAccelerator() + { + return this.quartzGrowthAccelerator; + } + + @Override + public ITileDefinition energyCell() + { + return this.energyCell; + } + + @Override + public ITileDefinition energyCellDense() + { + return this.energyCellDense; + } + + @Override + public ITileDefinition energyCellCreative() + { + return this.energyCellCreative; + } + + @Override + public ITileDefinition craftingUnit() + { + return this.craftingUnit; + } + + @Override + public ITileDefinition craftingAccelerator() + { + return this.craftingAccelerator; + } + + @Override + public ITileDefinition craftingStorage1k() + { + return this.craftingStorage1k; + } + + @Override + public ITileDefinition craftingStorage4k() + { + return this.craftingStorage4k; + } + + @Override + public ITileDefinition craftingStorage16k() + { + return this.craftingStorage16k; + } + + @Override + public ITileDefinition craftingStorage64k() + { + return this.craftingStorage64k; + } + + @Override + public ITileDefinition craftingMonitor() + { + return this.craftingMonitor; + } + + @Override + public ITileDefinition molecularAssembler() + { + return this.molecularAssembler; + } + + @Override + public ITileDefinition lightDetector() + { + return this.lightDetector; + } + + @Override + public ITileDefinition paint() + { + return this.paint; + } + + public IBlockDefinition chunkLoader() + { + return this.chunkLoader; + } + + public IBlockDefinition itemGen() + { + return this.itemGen; + } + + public IBlockDefinition phantomNode() + { + return this.phantomNode; + } + + public IBlockDefinition cubeGenerator() + { + return this.cubeGenerator; + } + + public Set orientables() + { + return this.orientables; + } +} diff --git a/src/main/java/appeng/core/api/definitions/ApiItems.java b/src/main/java/appeng/core/api/definitions/ApiItems.java new file mode 100644 index 000000000..d98816c9f --- /dev/null +++ b/src/main/java/appeng/core/api/definitions/ApiItems.java @@ -0,0 +1,418 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.core.api.definitions; + + +import appeng.api.definitions.IItemDefinition; +import appeng.api.definitions.IItems; +import appeng.api.util.AEColoredItemDefinition; +import appeng.core.features.AEFeature; +import appeng.debug.ToolDebugCard; +import appeng.debug.ToolEraser; +import appeng.debug.ToolMeteoritePlacer; +import appeng.debug.ToolReplicatorCard; +import appeng.items.materials.MaterialType; +import appeng.items.misc.ItemCrystalSeed; +import appeng.items.misc.ItemEncodedPattern; +import appeng.items.misc.ItemPaintBall; +import appeng.items.parts.ItemFacade; +import appeng.items.storage.ItemBasicStorageCell; +import appeng.items.storage.ItemCreativeStorageCell; +import appeng.items.storage.ItemSpatialStorageCell; +import appeng.items.storage.ItemViewCell; +import appeng.items.tools.ToolBiometricCard; +import appeng.items.tools.ToolMemoryCard; +import appeng.items.tools.ToolNetworkTool; +import appeng.items.tools.powered.ToolChargedStaff; +import appeng.items.tools.powered.ToolColorApplicator; +import appeng.items.tools.powered.ToolEntropyManipulator; +import appeng.items.tools.powered.ToolMassCannon; +import appeng.items.tools.powered.ToolPortableCell; +import appeng.items.tools.powered.ToolWirelessTerminal; +import appeng.items.tools.quartz.ToolQuartzAxe; +import appeng.items.tools.quartz.ToolQuartzCuttingKnife; +import appeng.items.tools.quartz.ToolQuartzHoe; +import appeng.items.tools.quartz.ToolQuartzPickaxe; +import appeng.items.tools.quartz.ToolQuartzSpade; +import appeng.items.tools.quartz.ToolQuartzSword; +import appeng.items.tools.quartz.ToolQuartzWrench; + + +/** + * Internal implementation for the API items + */ +public final class ApiItems implements IItems +{ + private final IItemDefinition certusQuartzAxe; + private final IItemDefinition certusQuartzHoe; + private final IItemDefinition certusQuartzShovel; + private final IItemDefinition certusQuartzPick; + private final IItemDefinition certusQuartzSword; + private final IItemDefinition certusQuartzWrench; + private final IItemDefinition certusQuartzKnife; + + private final IItemDefinition netherQuartzAxe; + private final IItemDefinition netherQuartzHoe; + private final IItemDefinition netherQuartzShovel; + private final IItemDefinition netherQuartzPick; + private final IItemDefinition netherQuartzSword; + private final IItemDefinition netherQuartzWrench; + private final IItemDefinition netherQuartzKnife; + + private final IItemDefinition entropyManipulator; + private final IItemDefinition wirelessTerminal; + private final IItemDefinition biometricCard; + private final IItemDefinition chargedStaff; + private final IItemDefinition massCannon; + private final IItemDefinition memoryCard; + private final IItemDefinition networkTool; + private final IItemDefinition portableCell; + + private final IItemDefinition cellCreative; + private final IItemDefinition viewCell; + + private final IItemDefinition cell1k; + private final IItemDefinition cell4k; + private final IItemDefinition cell16k; + private final IItemDefinition cell64k; + + private final IItemDefinition spatialCell2; + private final IItemDefinition spatialCell16; + private final IItemDefinition spatialCell128; + + private final IItemDefinition facade; + private final IItemDefinition crystalSeed; + + // rv1 + private final IItemDefinition encodedPattern; + private final IItemDefinition colorApplicator; + + private final IItemDefinition paintBall; + private final AEColoredItemDefinition coloredPaintBall; + private final AEColoredItemDefinition coloredLumenPaintBall; + + // unsupported dev tools + private final IItemDefinition toolEraser; + private final IItemDefinition toolMeteoritePlacer; + private final IItemDefinition toolDebugCard; + private final IItemDefinition toolReplicatorCard; + + public ApiItems( DefinitionConstructor constructor ) + { + this.certusQuartzAxe = constructor.registerItemDefinition( new ToolQuartzAxe( AEFeature.CertusQuartzTools ) ); + this.certusQuartzHoe = constructor.registerItemDefinition( new ToolQuartzHoe( AEFeature.CertusQuartzTools ) ); + this.certusQuartzShovel = constructor.registerItemDefinition( new ToolQuartzSpade( AEFeature.CertusQuartzTools ) ); + this.certusQuartzPick = constructor.registerItemDefinition( new ToolQuartzPickaxe( AEFeature.CertusQuartzTools ) ); + this.certusQuartzSword = constructor.registerItemDefinition( new ToolQuartzSword( AEFeature.CertusQuartzTools ) ); + this.certusQuartzWrench = constructor.registerItemDefinition( new ToolQuartzWrench( AEFeature.CertusQuartzTools ) ); + this.certusQuartzKnife = constructor.registerItemDefinition( new ToolQuartzCuttingKnife( AEFeature.CertusQuartzTools ) ); + + this.netherQuartzAxe = constructor.registerItemDefinition( new ToolQuartzAxe( AEFeature.NetherQuartzTools ) ); + this.netherQuartzHoe = constructor.registerItemDefinition( new ToolQuartzHoe( AEFeature.NetherQuartzTools ) ); + this.netherQuartzShovel = constructor.registerItemDefinition( new ToolQuartzSpade( AEFeature.NetherQuartzTools ) ); + this.netherQuartzPick = constructor.registerItemDefinition( new ToolQuartzPickaxe( AEFeature.NetherQuartzTools ) ); + this.netherQuartzSword = constructor.registerItemDefinition( new ToolQuartzSword( AEFeature.NetherQuartzTools ) ); + this.netherQuartzWrench = constructor.registerItemDefinition( new ToolQuartzWrench( AEFeature.NetherQuartzTools ) ); + this.netherQuartzKnife = constructor.registerItemDefinition( new ToolQuartzCuttingKnife( AEFeature.NetherQuartzTools ) ); + + this.entropyManipulator = constructor.registerItemDefinition( new ToolEntropyManipulator() ); + this.wirelessTerminal = constructor.registerItemDefinition( new ToolWirelessTerminal() ); + this.biometricCard = constructor.registerItemDefinition( new ToolBiometricCard() ); + this.chargedStaff = constructor.registerItemDefinition( new ToolChargedStaff() ); + this.massCannon = constructor.registerItemDefinition( new ToolMassCannon() ); + this.memoryCard = constructor.registerItemDefinition( new ToolMemoryCard() ); + this.networkTool = constructor.registerItemDefinition( new ToolNetworkTool() ); + this.portableCell = constructor.registerItemDefinition( new ToolPortableCell() ); + + this.cellCreative = constructor.registerItemDefinition( new ItemCreativeStorageCell() ); + this.viewCell = constructor.registerItemDefinition( new ItemViewCell() ); + + this.cell1k = constructor.registerItemDefinition( new ItemBasicStorageCell( MaterialType.Cell1kPart, 1 ) ); + this.cell4k = constructor.registerItemDefinition( new ItemBasicStorageCell( MaterialType.Cell4kPart, 4 ) ); + this.cell16k = constructor.registerItemDefinition( new ItemBasicStorageCell( MaterialType.Cell16kPart, 16 ) ); + this.cell64k = constructor.registerItemDefinition( new ItemBasicStorageCell( MaterialType.Cell64kPart, 64 ) ); + + this.spatialCell2 = constructor.registerItemDefinition( new ItemSpatialStorageCell( 2 ) ); + this.spatialCell16 = constructor.registerItemDefinition( new ItemSpatialStorageCell( 16 ) ); + this.spatialCell128 = constructor.registerItemDefinition( new ItemSpatialStorageCell( 128 ) ); + + this.facade = constructor.registerItemDefinition( new ItemFacade() ); + this.crystalSeed = constructor.registerItemDefinition( new ItemCrystalSeed() ); + + // rv1 + this.encodedPattern = constructor.registerItemDefinition( new ItemEncodedPattern() ); + this.colorApplicator = constructor.registerItemDefinition( new ToolColorApplicator() ); + + this.paintBall = constructor.registerItemDefinition( new ItemPaintBall() ); + this.coloredPaintBall = constructor.constructColoredDefinition( this.paintBall, 0 ); + this.coloredLumenPaintBall = constructor.constructColoredDefinition( this.paintBall, 20 ); + + this.toolEraser = constructor.registerItemDefinition( new ToolEraser() ); + this.toolMeteoritePlacer = constructor.registerItemDefinition( new ToolMeteoritePlacer() ); + this.toolDebugCard = constructor.registerItemDefinition( new ToolDebugCard() ); + this.toolReplicatorCard = constructor.registerItemDefinition( new ToolReplicatorCard() ); + } + + @Override + public IItemDefinition certusQuartzAxe() + { + return this.certusQuartzAxe; + } + + @Override + public IItemDefinition certusQuartzHoe() + { + return this.certusQuartzHoe; + } + + @Override + public IItemDefinition certusQuartzShovel() + { + return this.certusQuartzShovel; + } + + @Override + public IItemDefinition certusQuartzPick() + { + return this.certusQuartzPick; + } + + @Override + public IItemDefinition certusQuartzSword() + { + return this.certusQuartzSword; + } + + @Override + public IItemDefinition certusQuartzWrench() + { + return this.certusQuartzWrench; + } + + @Override + public IItemDefinition certusQuartzKnife() + { + return this.certusQuartzKnife; + } + + @Override + public IItemDefinition netherQuartzAxe() + { + return this.netherQuartzAxe; + } + + @Override + public IItemDefinition netherQuartzHoe() + { + return this.netherQuartzHoe; + } + + @Override + public IItemDefinition netherQuartzShovel() + { + return this.netherQuartzShovel; + } + + @Override + public IItemDefinition netherQuartzPick() + { + return this.netherQuartzPick; + } + + @Override + public IItemDefinition netherQuartzSword() + { + return this.netherQuartzSword; + } + + @Override + public IItemDefinition netherQuartzWrench() + { + return this.netherQuartzWrench; + } + + @Override + public IItemDefinition netherQuartzKnife() + { + return this.netherQuartzKnife; + } + + @Override + public IItemDefinition entropyManipulator() + { + return this.entropyManipulator; + } + + @Override + public IItemDefinition wirelessTerminal() + { + return this.wirelessTerminal; + } + + @Override + public IItemDefinition biometricCard() + { + return this.biometricCard; + } + + @Override + public IItemDefinition chargedStaff() + { + return this.memoryCard; + } + + @Override + public IItemDefinition massCannon() + { + return this.massCannon; + } + + @Override + public IItemDefinition memoryCard() + { + return this.memoryCard; + } + + @Override + public IItemDefinition networkTool() + { + return this.networkTool; + } + + @Override + public IItemDefinition portableCell() + { + return this.portableCell; + } + + @Override + public IItemDefinition cellCreative() + { + return this.cellCreative; + } + + @Override + public IItemDefinition viewCell() + { + return this.viewCell; + } + + @Override + public IItemDefinition cell1k() + { + return this.cell1k; + } + + @Override + public IItemDefinition cell4k() + { + return this.cell4k; + } + + @Override + public IItemDefinition cell16k() + { + return this.cell16k; + } + + @Override + public IItemDefinition cell64k() + { + return this.cell64k; + } + + @Override + public IItemDefinition spatialCell2() + { + return this.spatialCell2; + } + + @Override + public IItemDefinition spatialCell16() + { + return this.spatialCell16; + } + + @Override + public IItemDefinition spatialCell128() + { + return this.spatialCell128; + } + + @Override + public IItemDefinition facade() + { + return this.facade; + } + + @Override + public IItemDefinition crystalSeed() + { + return this.crystalSeed; + } + + @Override + public IItemDefinition encodedPattern() + { + return this.encodedPattern; + } + + @Override + public IItemDefinition colorApplicator() + { + return this.colorApplicator; + } + + @Override + public AEColoredItemDefinition coloredPaintBall() + { + return this.coloredPaintBall; + } + + @Override + public AEColoredItemDefinition coloredLumenPaintBall() + { + return this.coloredLumenPaintBall; + } + + public IItemDefinition paintBall() + { + return this.paintBall; + } + + public IItemDefinition toolEraser() + { + return this.toolEraser; + } + + public IItemDefinition toolMeteoritePlacer() + { + return this.toolMeteoritePlacer; + } + + public IItemDefinition toolDebugCard() + { + return this.toolDebugCard; + } + + public IItemDefinition toolReplicatorCard() + { + return this.toolReplicatorCard; + } +} diff --git a/src/main/java/appeng/core/api/definitions/ApiMaterials.java b/src/main/java/appeng/core/api/definitions/ApiMaterials.java new file mode 100644 index 000000000..4deb5f0e6 --- /dev/null +++ b/src/main/java/appeng/core/api/definitions/ApiMaterials.java @@ -0,0 +1,507 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.core.api.definitions; + + +import appeng.api.definitions.IItemDefinition; +import appeng.api.definitions.IMaterials; +import appeng.core.features.DamagedItemDefinition; +import appeng.items.materials.ItemMultiMaterial; +import appeng.items.materials.MaterialType; + + +/** + * Internal implementation for the API materials + */ +public final class ApiMaterials implements IMaterials +{ + private final IItemDefinition cell2SpatialPart; + private final IItemDefinition cell16SpatialPart; + private final IItemDefinition cell128SpatialPart; + + private final IItemDefinition silicon; + private final IItemDefinition skyDust; + + private final IItemDefinition calcProcessorPress; + private final IItemDefinition engProcessorPress; + private final IItemDefinition logicProcessorPress; + + private final IItemDefinition calcProcessorPrint; + private final IItemDefinition engProcessorPrint; + private final IItemDefinition logicProcessorPrint; + + private final IItemDefinition siliconPress; + private final IItemDefinition siliconPrint; + + private final IItemDefinition namePress; + + private final IItemDefinition logicProcessor; + private final IItemDefinition calcProcessor; + private final IItemDefinition engProcessor; + + private final IItemDefinition basicCard; + private final IItemDefinition advCard; + + private final IItemDefinition purifiedCertusQuartzCrystal; + private final IItemDefinition purifiedNetherQuartzCrystal; + private final IItemDefinition purifiedFluixCrystal; + + private final IItemDefinition cell1kPart; + private final IItemDefinition cell4kPart; + private final IItemDefinition cell16kPart; + private final IItemDefinition cell64kPart; + private final IItemDefinition emptyStorageCell; + + private final IItemDefinition cardRedstone; + private final IItemDefinition cardSpeed; + private final IItemDefinition cardCapacity; + private final IItemDefinition cardFuzzy; + private final IItemDefinition cardInverter; + private final IItemDefinition cardCrafting; + + private final IItemDefinition enderDust; + private final IItemDefinition flour; + private final IItemDefinition goldDust; + private final IItemDefinition ironDust; + private final IItemDefinition fluixDust; + private final IItemDefinition certusQuartzDust; + private final IItemDefinition netherQuartzDust; + + private final IItemDefinition matterBall; + private final IItemDefinition ironNugget; + + private final IItemDefinition certusQuartzCrystal; + private final IItemDefinition certusQuartzCrystalCharged; + private final IItemDefinition fluixCrystal; + private final IItemDefinition fluixPearl; + + private final IItemDefinition woodenGear; + + private final IItemDefinition wireless; + private final IItemDefinition wirelessBooster; + + private final IItemDefinition annihilationCore; + private final IItemDefinition formationCore; + + private final IItemDefinition singularity; + private final IItemDefinition qESingularity; + private final IItemDefinition blankPattern; + + public ApiMaterials( DefinitionConstructor constructor ) + { + final ItemMultiMaterial itemMultiMaterial = new ItemMultiMaterial(); + constructor.registerItemDefinition( itemMultiMaterial ); + + this.cell2SpatialPart = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.Cell2SpatialPart ) ); + this.cell16SpatialPart = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.Cell16SpatialPart ) ); + this.cell128SpatialPart = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.Cell128SpatialPart ) ); + + this.silicon = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.Silicon ) ); + this.skyDust = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.SkyDust ) ); + + this.calcProcessorPress = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.CalcProcessorPress ) ); + this.engProcessorPress = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.EngProcessorPress ) ); + this.logicProcessorPress = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.LogicProcessorPress ) ); + + this.calcProcessorPrint = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.CalcProcessorPrint ) ); + this.engProcessorPrint = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.EngProcessorPrint ) ); + this.logicProcessorPrint = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.LogicProcessorPrint ) ); + + this.siliconPress = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.SiliconPress ) ); + this.siliconPrint = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.SiliconPrint ) ); + + this.namePress = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.NamePress ) ); + + this.logicProcessor = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.LogicProcessor ) ); + this.calcProcessor = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.CalcProcessor ) ); + this.engProcessor = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.EngProcessor ) ); + + this.basicCard = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.BasicCard ) ); + this.advCard = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.AdvCard ) ); + + this.purifiedCertusQuartzCrystal = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.PurifiedCertusQuartzCrystal ) ); + this.purifiedNetherQuartzCrystal = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.PurifiedNetherQuartzCrystal ) ); + this.purifiedFluixCrystal = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.PurifiedFluixCrystal ) ); + + this.cell1kPart = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.Cell1kPart ) ); + this.cell4kPart = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.Cell4kPart ) ); + this.cell16kPart = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.Cell16kPart ) ); + this.cell64kPart = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.Cell64kPart ) ); + this.emptyStorageCell = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.EmptyStorageCell ) ); + + this.cardRedstone = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.CardRedstone ) ); + this.cardSpeed = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.CardSpeed ) ); + this.cardCapacity = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.CardCapacity ) ); + this.cardFuzzy = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.CardFuzzy ) ); + this.cardInverter = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.CardInverter ) ); + this.cardCrafting = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.CardCrafting ) ); + + this.enderDust = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.EnderDust ) ); + this.flour = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.Flour ) ); + this.goldDust = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.GoldDust ) ); + this.ironDust = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.IronDust ) ); + this.fluixDust = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.FluixDust ) ); + this.certusQuartzDust = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.CertusQuartzDust ) ); + this.netherQuartzDust = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.NetherQuartzDust ) ); + + this.matterBall = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.MatterBall ) ); + this.ironNugget = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.IronNugget ) ); + + this.certusQuartzCrystal = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.CertusQuartzCrystal ) ); + this.certusQuartzCrystalCharged = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.CertusQuartzCrystalCharged ) ); + this.fluixCrystal = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.FluixCrystal ) ); + this.fluixPearl = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.FluixPearl ) ); + + this.woodenGear = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.WoodenGear ) ); + + this.wireless = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.Wireless ) ); + this.wirelessBooster = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.WirelessBooster ) ); + + this.annihilationCore = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.AnnihilationCore ) ); + this.formationCore = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.FormationCore ) ); + + this.singularity = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.Singularity ) ); + this.qESingularity = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.QESingularity ) ); + this.blankPattern = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.BlankPattern ) ); + } + + @Override + public IItemDefinition cell2SpatialPart() + { + return this.cell2SpatialPart; + } + + @Override + public IItemDefinition cell16SpatialPart() + { + return this.cell16SpatialPart; + } + + @Override + public IItemDefinition cell128SpatialPart() + { + return this.cell128SpatialPart; + } + + @Override + public IItemDefinition silicon() + { + return this.silicon; + } + + @Override + public IItemDefinition skyDust() + { + return this.skyDust; + } + + @Override + public IItemDefinition calcProcessorPress() + { + return this.calcProcessorPress; + } + + @Override + public IItemDefinition engProcessorPress() + { + return this.engProcessorPress; + } + + @Override + public IItemDefinition logicProcessorPress() + { + return this.logicProcessorPress; + } + + @Override + public IItemDefinition calcProcessorPrint() + { + return this.calcProcessorPrint; + } + + @Override + public IItemDefinition engProcessorPrint() + { + return this.engProcessorPrint; + } + + @Override + public IItemDefinition logicProcessorPrint() + { + return this.logicProcessorPrint; + } + + @Override + public IItemDefinition siliconPress() + { + return this.siliconPress; + } + + @Override + public IItemDefinition siliconPrint() + { + return this.siliconPrint; + } + + @Override + public IItemDefinition namePress() + { + return this.namePress; + } + + @Override + public IItemDefinition logicProcessor() + { + return this.logicProcessor; + } + + @Override + public IItemDefinition calcProcessor() + { + return this.calcProcessor; + } + + @Override + public IItemDefinition engProcessor() + { + return this.engProcessor; + } + + @Override + public IItemDefinition basicCard() + { + return this.basicCard; + } + + @Override + public IItemDefinition advCard() + { + return this.advCard; + } + + @Override + public IItemDefinition purifiedCertusQuartzCrystal() + { + return this.purifiedCertusQuartzCrystal; + } + + @Override + public IItemDefinition purifiedNetherQuartzCrystal() + { + return this.purifiedNetherQuartzCrystal; + } + + @Override + public IItemDefinition purifiedFluixCrystal() + { + return this.purifiedFluixCrystal; + } + + @Override + public IItemDefinition cell1kPart() + { + return this.cell1kPart; + } + + @Override + public IItemDefinition cell4kPart() + { + return this.cell4kPart; + } + + @Override + public IItemDefinition cell16kPart() + { + return this.cell16kPart; + } + + @Override + public IItemDefinition cell64kPart() + { + return this.cell64kPart; + } + + @Override + public IItemDefinition emptyStorageCell() + { + return this.emptyStorageCell; + } + + @Override + public IItemDefinition cardRedstone() + { + return this.cardRedstone; + } + + @Override + public IItemDefinition cardSpeed() + { + return this.cardSpeed; + } + + @Override + public IItemDefinition cardCapacity() + { + return this.cardCapacity; + } + + @Override + public IItemDefinition cardFuzzy() + { + return this.cardFuzzy; + } + + @Override + public IItemDefinition cardInverter() + { + return this.cardInverter; + } + + @Override + public IItemDefinition cardCrafting() + { + return this.cardCrafting; + } + + @Override + public IItemDefinition enderDust() + { + return this.enderDust; + } + + @Override + public IItemDefinition flour() + { + return this.flour; + } + + @Override + public IItemDefinition goldDust() + { + return this.goldDust; + } + + @Override + public IItemDefinition ironDust() + { + return this.ironDust; + } + + @Override + public IItemDefinition fluixDust() + { + return this.fluixDust; + } + + @Override + public IItemDefinition certusQuartzDust() + { + return this.certusQuartzDust; + } + + @Override + public IItemDefinition netherQuartzDust() + { + return this.netherQuartzDust; + } + + @Override + public IItemDefinition matterBall() + { + return this.matterBall; + } + + @Override + public IItemDefinition ironNugget() + { + return this.ironNugget; + } + + @Override + public IItemDefinition certusQuartzCrystal() + { + return this.certusQuartzCrystal; + } + + @Override + public IItemDefinition certusQuartzCrystalCharged() + { + return this.certusQuartzCrystalCharged; + } + + @Override + public IItemDefinition fluixCrystal() + { + return this.fluixCrystal; + } + + @Override + public IItemDefinition fluixPearl() + { + return this.fluixPearl; + } + + @Override + public IItemDefinition woodenGear() + { + return this.woodenGear; + } + + @Override + public IItemDefinition wireless() + { + return this.wireless; + } + + @Override + public IItemDefinition wirelessBooster() + { + return this.wirelessBooster; + } + + @Override + public IItemDefinition annihilationCore() + { + return this.annihilationCore; + } + + @Override + public IItemDefinition formationCore() + { + return this.formationCore; + } + + @Override + public IItemDefinition singularity() + { + return this.singularity; + } + + @Override + public IItemDefinition qESingularity() + { + return this.qESingularity; + } + + @Override + public IItemDefinition blankPattern() + { + return this.blankPattern; + } +} diff --git a/src/main/java/appeng/core/api/definitions/ApiParts.java b/src/main/java/appeng/core/api/definitions/ApiParts.java new file mode 100644 index 000000000..c8bea230a --- /dev/null +++ b/src/main/java/appeng/core/api/definitions/ApiParts.java @@ -0,0 +1,328 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.core.api.definitions; + + +import appeng.api.definitions.IItemDefinition; +import appeng.api.definitions.IParts; +import appeng.api.exceptions.MissingDefinition; +import appeng.api.parts.IPartHelper; +import appeng.api.util.AEColoredItemDefinition; +import appeng.core.features.DamagedItemDefinition; +import appeng.items.parts.ItemMultiPart; +import appeng.items.parts.PartType; + + +/** + * Internal implementation for the API parts + */ +public final class ApiParts implements IParts +{ + private final AEColoredItemDefinition cableSmart; + private final AEColoredItemDefinition cableCovered; + private final AEColoredItemDefinition cableGlass; + private final AEColoredItemDefinition cableDense; +// private final AEColoredItemDefinition lumenCableSmart; +// private final AEColoredItemDefinition lumenCableCovered; +// private final AEColoredItemDefinition lumenCableGlass; +// private final AEColoredItemDefinition lumenCableDense; + private final IItemDefinition quartzFiber; + private final IItemDefinition toggleBus; + private final IItemDefinition invertedToggleBus; + private final IItemDefinition storageBus; + private final IItemDefinition importBus; + private final IItemDefinition exportBus; + private final IItemDefinition iface; + private final IItemDefinition levelEmitter; + private final IItemDefinition annihilationPlane; + private final IItemDefinition formationPlane; + private final IItemDefinition p2PTunnelME; + private final IItemDefinition p2PTunnelRedstone; + private final IItemDefinition p2PTunnelItems; + private final IItemDefinition p2PTunnelLiquids; + private final IItemDefinition p2PTunnelEU; + private final IItemDefinition p2PTunnelRF; + private final IItemDefinition p2PTunnelLight; + private final IItemDefinition cableAnchor; + private final IItemDefinition monitor; + private final IItemDefinition semiDarkMonitor; + private final IItemDefinition darkMonitor; + private final IItemDefinition interfaceTerminal; + private final IItemDefinition patternTerminal; + private final IItemDefinition craftingTerminal; + private final IItemDefinition terminal; + private final IItemDefinition storageMonitor; + private final IItemDefinition conversionMonitor; + + public ApiParts( DefinitionConstructor constructor, IPartHelper partHelper ) + { + final ItemMultiPart itemMultiPart = new ItemMultiPart( partHelper ); + constructor.registerItemDefinition( itemMultiPart ); + + this.cableSmart = constructor.constructColoredDefinition( itemMultiPart, PartType.CableSmart ); + this.cableCovered = constructor.constructColoredDefinition( itemMultiPart, PartType.CableCovered ); + this.cableGlass = constructor.constructColoredDefinition( itemMultiPart, PartType.CableGlass ); + this.cableDense = constructor.constructColoredDefinition( itemMultiPart, PartType.CableDense ); +// this.lumenCableSmart = Optional.absent(); // has yet to be implemented, no PartType defined for it yet +// this.lumenCableCovered = Optional.absent(); // has yet to be implemented, no PartType defined for it yet +// this.lumenCableGlass = Optional.absent(); // has yet to be implemented, no PartType defined for it yet +// this.lumenCableDense = Optional.absent(); // has yet to be implemented, no PartType defined for it yet + this.quartzFiber = new DamagedItemDefinition( itemMultiPart.createPart( PartType.QuartzFiber ) ); + this.toggleBus = new DamagedItemDefinition( itemMultiPart.createPart( PartType.ToggleBus ) ); + this.invertedToggleBus = new DamagedItemDefinition( itemMultiPart.createPart( PartType.InvertedToggleBus ) ); + this.storageBus = new DamagedItemDefinition( itemMultiPart.createPart( PartType.StorageBus ) ); + this.importBus = new DamagedItemDefinition( itemMultiPart.createPart( PartType.ImportBus ) ); + this.exportBus = new DamagedItemDefinition( itemMultiPart.createPart( PartType.ExportBus ) ); + this.iface = new DamagedItemDefinition( itemMultiPart.createPart( PartType.Interface ) ); + this.levelEmitter = new DamagedItemDefinition( itemMultiPart.createPart( PartType.LevelEmitter ) ); + this.annihilationPlane = new DamagedItemDefinition( itemMultiPart.createPart( PartType.AnnihilationPlane ) ); + this.formationPlane = new DamagedItemDefinition( itemMultiPart.createPart( PartType.FormationPlane ) ); + this.p2PTunnelME = new DamagedItemDefinition( itemMultiPart.createPart( PartType.P2PTunnelME ) ); + this.p2PTunnelRedstone = new DamagedItemDefinition( itemMultiPart.createPart( PartType.P2PTunnelRedstone ) ); + this.p2PTunnelItems = new DamagedItemDefinition( itemMultiPart.createPart( PartType.P2PTunnelItems ) ); + this.p2PTunnelLiquids = new DamagedItemDefinition( itemMultiPart.createPart( PartType.P2PTunnelLiquids ) ); + this.p2PTunnelEU = new DamagedItemDefinition( itemMultiPart.createPart( PartType.P2PTunnelEU ) ); + this.p2PTunnelRF = new DamagedItemDefinition( itemMultiPart.createPart( PartType.P2PTunnelRF ) ); + this.p2PTunnelLight = new DamagedItemDefinition( itemMultiPart.createPart( PartType.P2PTunnelLight ) ); + this.cableAnchor = new DamagedItemDefinition( itemMultiPart.createPart( PartType.CableAnchor ) ); + this.monitor = new DamagedItemDefinition( itemMultiPart.createPart( PartType.Monitor ) ); + this.semiDarkMonitor = new DamagedItemDefinition( itemMultiPart.createPart( PartType.SemiDarkMonitor ) ); + this.darkMonitor = new DamagedItemDefinition( itemMultiPart.createPart( PartType.DarkMonitor ) ); + this.interfaceTerminal = new DamagedItemDefinition( itemMultiPart.createPart( PartType.InterfaceTerminal ) ); + this.patternTerminal = new DamagedItemDefinition( itemMultiPart.createPart( PartType.PatternTerminal ) ); + this.craftingTerminal = new DamagedItemDefinition( itemMultiPart.createPart( PartType.CraftingTerminal ) ); + this.terminal = new DamagedItemDefinition( itemMultiPart.createPart( PartType.Terminal ) ); + this.storageMonitor = new DamagedItemDefinition( itemMultiPart.createPart( PartType.StorageMonitor ) ); + this.conversionMonitor = new DamagedItemDefinition( itemMultiPart.createPart( PartType.ConversionMonitor ) ); + } + + @Override + public AEColoredItemDefinition cableSmart() + { + return this.cableSmart; + } + + @Override + public AEColoredItemDefinition cableCovered() + { + return this.cableCovered; + } + + @Override + public AEColoredItemDefinition cableGlass() + { + return this.cableGlass; + } + + @Override + public AEColoredItemDefinition cableDense() + { + return this.cableDense; + } + + @Override + public AEColoredItemDefinition lumenCableSmart() + { + throw new MissingDefinition( "Lumen Smart Cable has yet to be implemented." ); +// return this.lumenCableSmart; + } + + @Override + public AEColoredItemDefinition lumenCableCovered() + { + throw new MissingDefinition( "Lumen Covered Cable has yet to be implemented." ); +// return this.lumenCableCovered; + } + + @Override + public AEColoredItemDefinition lumenCableGlass() + { + throw new MissingDefinition( "Lumen Glass Cable has yet to be implemented." ); +// return this.lumenCableGlass; + } + + @Override + public AEColoredItemDefinition lumenCableDense() + { + throw new MissingDefinition( "Lumen Dense Cable has yet to be implemented." ); +// return this.lumenCableDense; + } + + @Override + public IItemDefinition quartzFiber() + { + return this.quartzFiber; + } + + @Override + public IItemDefinition toggleBus() + { + return this.toggleBus; + } + + @Override + public IItemDefinition invertedToggleBus() + { + return this.invertedToggleBus; + } + + @Override + public IItemDefinition storageBus() + { + return this.storageBus; + } + + @Override + public IItemDefinition importBus() + { + return this.importBus; + } + + @Override + public IItemDefinition exportBus() + { + return this.exportBus; + } + + @Override + public IItemDefinition iface() + { + return this.iface; + } + + @Override + public IItemDefinition levelEmitter() + { + return this.levelEmitter; + } + + @Override + public IItemDefinition annihilationPlane() + { + return this.annihilationPlane; + } + + @Override + public IItemDefinition formationPlane() + { + return this.formationPlane; + } + + @Override + public IItemDefinition p2PTunnelME() + { + return this.p2PTunnelME; + } + + @Override + public IItemDefinition p2PTunnelRedstone() + { + return this.p2PTunnelRedstone; + } + + @Override + public IItemDefinition p2PTunnelItems() + { + return this.p2PTunnelItems; + } + + @Override + public IItemDefinition p2PTunnelLiquids() + { + return this.p2PTunnelLiquids; + } + + @Override + public IItemDefinition p2PTunnelEU() + { + return this.p2PTunnelEU; + } + + @Override + public IItemDefinition p2PTunnelRF() + { + return this.p2PTunnelRF; + } + + @Override + public IItemDefinition p2PTunnelLight() + { + return this.p2PTunnelLight; + } + + @Override + public IItemDefinition cableAnchor() + { + return this.cableAnchor; + } + + @Override + public IItemDefinition monitor() + { + return this.monitor; + } + + @Override + public IItemDefinition semiDarkMonitor() + { + return this.semiDarkMonitor; + } + + @Override + public IItemDefinition darkMonitor() + { + return this.darkMonitor; + } + + @Override + public IItemDefinition interfaceTerminal() + { + return this.interfaceTerminal; + } + + @Override + public IItemDefinition patternTerminal() + { + return this.patternTerminal; + } + + @Override + public IItemDefinition craftingTerminal() + { + return this.craftingTerminal; + } + + @Override + public IItemDefinition terminal() + { + return this.terminal; + } + + @Override + public IItemDefinition storageMonitor() + { + return this.storageMonitor; + } + + @Override + public IItemDefinition conversionMonitor() + { + return this.conversionMonitor; + } +} diff --git a/src/main/java/appeng/core/api/definitions/DefinitionConstructor.java b/src/main/java/appeng/core/api/definitions/DefinitionConstructor.java new file mode 100644 index 000000000..4a88c8155 --- /dev/null +++ b/src/main/java/appeng/core/api/definitions/DefinitionConstructor.java @@ -0,0 +1,105 @@ +package appeng.core.api.definitions; + + +import net.minecraft.item.Item; + +import com.google.common.base.Optional; + +import appeng.api.definitions.IBlockDefinition; +import appeng.api.definitions.IItemDefinition; +import appeng.api.definitions.ITileDefinition; +import appeng.api.util.AEColor; +import appeng.api.util.AEColoredItemDefinition; +import appeng.core.FeatureHandlerRegistry; +import appeng.core.FeatureRegistry; +import appeng.core.features.ColoredItemDefinition; +import appeng.core.features.IAEFeature; +import appeng.core.features.IFeatureHandler; +import appeng.core.features.ItemStackSrc; +import appeng.items.parts.ItemMultiPart; +import appeng.items.parts.PartType; + + +public class DefinitionConstructor +{ + private final FeatureRegistry features; + private final FeatureHandlerRegistry handlers; + + public DefinitionConstructor( FeatureRegistry features, FeatureHandlerRegistry handlers ) + { + this.features = features; + this.handlers = handlers; + } + + public final ITileDefinition registerTileDefinition( IAEFeature feature ) + { + final IBlockDefinition definition = this.registerBlockDefinition( feature ); + + if ( definition instanceof ITileDefinition ) + { + return ( (ITileDefinition) definition ); + } + + throw new RuntimeException( "No tile definition" ); + } + + public final IBlockDefinition registerBlockDefinition( IAEFeature feature ) + { + final IItemDefinition definition = this.registerItemDefinition( feature ); + + if ( definition instanceof IBlockDefinition ) + { + return ( (IBlockDefinition) definition ); + } + + throw new RuntimeException( "No block definition" ); + } + + public final IItemDefinition registerItemDefinition( IAEFeature feature ) + { + final IFeatureHandler handler = feature.handler(); + + if ( handler.isFeatureAvailable() ) + { + this.handlers.addFeatureHandler( handler ); + this.features.addFeature( feature ); + } + + final IItemDefinition definition = handler.getDefinition(); + + return definition; + } + + public final AEColoredItemDefinition constructColoredDefinition( IItemDefinition target, int offset ) + { + final ColoredItemDefinition definition = new ColoredItemDefinition(); + + for ( Item targetItem : target.maybeItem().asSet() ) + { + for ( AEColor color : AEColor.VALID_COLORS ) + { + definition.add( color, new ItemStackSrc( targetItem, offset + color.ordinal() ) ); + } + } + + return definition; + } + + public final AEColoredItemDefinition constructColoredDefinition( ItemMultiPart target, PartType type ) + { + final ColoredItemDefinition definition = new ColoredItemDefinition(); + + for ( AEColor color : AEColor.values() ) + { + ItemStackSrc multiPartSource = target.createPart( type, color ); + final Optional maybeSource = Optional.fromNullable( multiPartSource ); + + if ( maybeSource.isPresent() ) + { + definition.add( color, multiPartSource ); + } + } + + return definition; + } +} diff --git a/src/main/java/appeng/core/features/AEBlockFeatureHandler.java b/src/main/java/appeng/core/features/AEBlockFeatureHandler.java index b3d3df94d..5bd5b2337 100644 --- a/src/main/java/appeng/core/features/AEBlockFeatureHandler.java +++ b/src/main/java/appeng/core/features/AEBlockFeatureHandler.java @@ -21,11 +21,11 @@ package appeng.core.features; import java.util.EnumSet; -import com.google.common.base.Optional; - import cpw.mods.fml.common.registry.GameRegistry; -import appeng.api.util.AEItemDefinition; +import com.google.common.base.Optional; + +import appeng.api.definitions.ITileDefinition; import appeng.block.AEBaseBlock; import appeng.block.AEBaseItemBlock; import appeng.core.CommonHelper; @@ -33,21 +33,21 @@ import appeng.core.CreativeTab; import appeng.util.Platform; -public class AEBlockFeatureHandler implements IFeatureHandler +public final class AEBlockFeatureHandler implements IFeatureHandler { - private final EnumSet features; private final AEBaseBlock featured; private final FeatureNameExtractor extractor; private final boolean enabled; - private final AEBlockDefinition definition; + private final TileDefinition definition; public AEBlockFeatureHandler( EnumSet features, AEBaseBlock featured, Optional subName ) { - this.features = features; + final ActivityState state = new FeaturedActiveChecker( features ).getActivityState(); + this.featured = featured; this.extractor = new FeatureNameExtractor( featured.getClass(), subName ); - this.enabled = new FeaturedActiveChecker( features ).get(); - this.definition = new AEBlockDefinition( featured, this.enabled ); + this.enabled = state == ActivityState.Enabled; + this.definition = new TileDefinition( featured, state ); } @Override @@ -57,13 +57,7 @@ public class AEBlockFeatureHandler implements IFeatureHandler } @Override - public EnumSet getFeatures() - { - return this.features; - } - - @Override - public AEItemDefinition getDefinition() + public ITileDefinition getDefinition() { return this.definition; } diff --git a/src/main/java/appeng/core/features/AEFeatureHandler.java b/src/main/java/appeng/core/features/AEFeatureHandler.java deleted file mode 100644 index 996d758e1..000000000 --- a/src/main/java/appeng/core/features/AEFeatureHandler.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. - * - * Applied Energistics 2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Applied Energistics 2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Applied Energistics 2. If not, see . - */ - -package appeng.core.features; - - -import java.util.EnumSet; -import java.util.regex.Pattern; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockStairs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; - -import cpw.mods.fml.common.registry.GameRegistry; - -import appeng.api.util.AEItemDefinition; -import appeng.block.AEBaseBlock; -import appeng.block.AEBaseItemBlock; -import appeng.core.AEConfig; -import appeng.core.CommonHelper; -import appeng.core.CreativeTab; -import appeng.core.CreativeTabFacade; -import appeng.items.parts.ItemFacade; -import appeng.util.Platform; - - -public class AEFeatureHandler implements AEItemDefinition -{ - - private static final Pattern PATTERN_ITEM_MULTI_PART = Pattern.compile( "ItemMultiPart", Pattern.LITERAL ); - private static final Pattern PATTERN_ITEM_MULTI_MATERIAL = Pattern.compile( "ItemMultiMaterial", Pattern.LITERAL ); - private static final Pattern PATTERN_QUARTZ = Pattern.compile( "Quartz", Pattern.LITERAL ); - - private final EnumSet features; - - private final String subName; - private final IAEFeature feature; - - private Item ItemData; - private Block BlockData; - private BlockStairs stairData; - - public AEFeatureHandler( EnumSet features, IAEFeature feature, String subName ) - { - this.features = features; - this.feature = feature; - this.subName = subName; - } - - public void register() - { - if ( this.isFeatureAvailable() ) - { - if ( this.feature instanceof Item ) - { - this.initItem( ( Item ) this.feature ); - } - else if ( this.feature instanceof BlockStairs ) - { - this.initStairBlock( ( BlockStairs ) this.feature ); - } - else if ( this.feature instanceof Block ) - { - this.initBlock( ( Block ) this.feature ); - } - } - } - - public boolean isFeatureAvailable() - { - boolean enabled = true; - - for ( AEFeature f : this.features ) - enabled = enabled && AEConfig.instance.isFeatureEnabled( f ); - - return enabled; - } - - private void initItem( Item i ) - { - this.ItemData = i; - - String name = getName( i.getClass(), this.subName ); - i.setTextureName( "appliedenergistics2:" + name ); - i.setUnlocalizedName( /* "item." */"appliedenergistics2." + name ); - - if ( i instanceof ItemFacade ) - i.setCreativeTab( CreativeTabFacade.instance ); - else - i.setCreativeTab( CreativeTab.instance ); - - if ( name.equals( "ItemMaterial" ) ) - name = "ItemMultiMaterial"; - else if ( name.equals( "ItemPart" ) ) - name = "ItemMultiPart"; - - GameRegistry.registerItem( i, "item." + name ); - } - - private void initStairBlock( BlockStairs stair ) - { - this.stairData = stair; - - String name = getName( stair.getClass(), this.subName ); - stair.setCreativeTab( CreativeTab.instance ); - stair.setBlockName( /* "tile." */"appliedenergistics2." + name ); - stair.setBlockTextureName( "appliedenergistics2:" + name ); - - GameRegistry.registerBlock( stair, "tile." + name ); - } - - private void initBlock( Block b ) - { - this.BlockData = b; - - String name = getName( b.getClass(), this.subName ); - b.setCreativeTab( CreativeTab.instance ); - b.setBlockName( /* "tile." */"appliedenergistics2." + name ); - b.setBlockTextureName( "appliedenergistics2:" + name ); - - if ( Platform.isClient() && this.BlockData instanceof AEBaseBlock ) - { - AEBaseBlock bb = ( AEBaseBlock ) b; - CommonHelper.proxy.bindTileEntitySpecialRenderer( bb.getTileEntityClass(), bb ); - } - - Class itemBlock = AEBaseItemBlock.class; - if ( b instanceof AEBaseBlock ) - itemBlock = ( ( AEBaseBlock ) b ).getItemBlockClass(); - - GameRegistry.registerBlock( b, itemBlock, "tile." + name ); - } - - public static String getName( Class o, String subName ) - { - String name = o.getSimpleName(); - - if ( name.startsWith( "ItemMultiPart" ) ) - name = PATTERN_ITEM_MULTI_PART.matcher( name ).replaceAll( "ItemPart" ); - else if ( name.startsWith( "ItemMultiMaterial" ) ) - name = PATTERN_ITEM_MULTI_MATERIAL.matcher( name ).replaceAll( "ItemMaterial" ); - - if ( subName != null ) - { - // simple hack to allow me to do get nice names for these without - // mode code outside of AEBaseItem - if ( subName.startsWith( "P2PTunnel" ) ) - return "ItemPart.P2PTunnel"; - - if ( subName.equals( "CertusQuartzTools" ) ) - return PATTERN_QUARTZ.matcher( name ).replaceAll( "CertusQuartz" ); - if ( subName.equals( "NetherQuartzTools" ) ) - return PATTERN_QUARTZ.matcher( name ).replaceAll( "NetherQuartz" ); - - name += '.' + subName; - } - - return name; - } - - public EnumSet getFeatures() - { - return this.features.clone(); - } - - @Override - public Block block() - { - return this.BlockData; - } - - @Override - public Item item() - { - if ( this.ItemData != null ) - { - return this.ItemData; - } - else if ( this.BlockData != null ) - { - return Item.getItemFromBlock( this.BlockData ); - } - else if ( this.stairData != null ) - { - return Item.getItemFromBlock( this.stairData ); - } - - return null; - } - - @Override - public Class entity() - { - if ( this.BlockData instanceof AEBaseBlock ) - { - AEBaseBlock bb = ( AEBaseBlock ) this.BlockData; - return bb.getTileEntityClass(); - } - - return null; - } - - @Override - public ItemStack stack( int stackSize ) - { - if ( this.isFeatureAvailable() ) - { - ItemStack rv; - - if ( this.ItemData != null ) - rv = new ItemStack( this.ItemData ); - else - rv = new ItemStack( this.BlockData ); - - rv.stackSize = stackSize; - return rv; - } - - return null; - } - - @Override - public boolean sameAsStack( ItemStack is ) - { - return this.isFeatureAvailable() && Platform.isSameItemType( is, this.stack( 1 ) ); - } - - /** - * block at xyz in world is same if: - * - * - the feature is available - * - the stored block data is not null - * - and the stored block data is equal - * - * @param world world of block - * @param x x pos of block - * @param y y pos of block - * @param z z pos of block - * - * @return true if feature is available and the blocks are equal - */ - @Override - public boolean sameAsBlock( IBlockAccess world, int x, int y, int z ) - { - return this.isFeatureAvailable() && this.BlockData != null && world.getBlock( x, y, z ) == this.BlockData; - } - -} diff --git a/src/main/java/appeng/core/features/ActivityState.java b/src/main/java/appeng/core/features/ActivityState.java new file mode 100644 index 000000000..80f1bc0e0 --- /dev/null +++ b/src/main/java/appeng/core/features/ActivityState.java @@ -0,0 +1,7 @@ +package appeng.core.features; + + +public enum ActivityState +{ + Enabled, Disabled +} diff --git a/src/main/java/appeng/core/features/BlockDefinition.java b/src/main/java/appeng/core/features/BlockDefinition.java index 6b638a002..a1a912ee5 100644 --- a/src/main/java/appeng/core/features/BlockDefinition.java +++ b/src/main/java/appeng/core/features/BlockDefinition.java @@ -21,62 +21,61 @@ package appeng.core.features; import net.minecraft.block.Block; import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; -import appeng.api.util.AEItemDefinition; -import appeng.util.Platform; +import com.google.common.base.Optional; + +import appeng.api.definitions.IBlockDefinition; -public class BlockDefinition implements AEItemDefinition +public class BlockDefinition extends ItemDefinition implements IBlockDefinition { private final Block block; private final boolean enabled; - public BlockDefinition( Block block, boolean enabled ) + public BlockDefinition( Block block, ActivityState state ) { + super( Item.getItemFromBlock( block ), state ); this.block = block; - this.enabled = enabled; + this.enabled = state == ActivityState.Enabled; } @Override - public Block block() + public Optional maybeBlock() { - return this.block; + return Optional.of( this.block ); } @Override - public Item item() - { - return Item.getItemFromBlock( this.block ); - } - - @Override - public Class entity() - { - return null; - } - - @Override - public ItemStack stack( int stackSize ) + public Optional maybeItemBlock() { if ( this.enabled ) { - return new ItemStack( this.block ); + return Optional.of( new ItemBlock( this.block ) ); + } + else + { + return Optional.absent(); } - - return null; } @Override - public boolean sameAsStack( ItemStack comparableItem ) + public final Optional maybeStack( int stackSize ) { - return this.enabled && Platform.isSameItemType( comparableItem, this.stack( 1 ) ); + if ( this.enabled ) + { + return Optional.of( new ItemStack( this.block ) ); + } + else + { + return Optional.absent(); + } } @Override - public boolean sameAsBlock( IBlockAccess world, int x, int y, int z ) + public final boolean isSameAs( IBlockAccess world, int x, int y, int z ) { return this.enabled && world.getBlock( x, y, z ) == this.block; } diff --git a/src/main/java/appeng/core/features/ColoredItemDefinition.java b/src/main/java/appeng/core/features/ColoredItemDefinition.java index 4f789a76b..16fe7e4b2 100644 --- a/src/main/java/appeng/core/features/ColoredItemDefinition.java +++ b/src/main/java/appeng/core/features/ColoredItemDefinition.java @@ -26,7 +26,7 @@ import net.minecraft.tileentity.TileEntity; import appeng.api.util.AEColor; import appeng.api.util.AEColoredItemDefinition; -public class ColoredItemDefinition implements AEColoredItemDefinition +public final class ColoredItemDefinition implements AEColoredItemDefinition { final ItemStackSrc[] colors = new ItemStackSrc[17]; diff --git a/src/main/java/appeng/core/features/DamagedItemDefinition.java b/src/main/java/appeng/core/features/DamagedItemDefinition.java index 4b25f39e9..d6a6c0e84 100644 --- a/src/main/java/appeng/core/features/DamagedItemDefinition.java +++ b/src/main/java/appeng/core/features/DamagedItemDefinition.java @@ -18,60 +18,53 @@ package appeng.core.features; -import net.minecraft.block.Block; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; -import appeng.api.util.AEItemDefinition; +import com.google.common.base.Optional; -public class DamagedItemDefinition implements AEItemDefinition +import appeng.api.definitions.IItemDefinition; + + +public final class DamagedItemDefinition implements IItemDefinition { + private final IStackSrc source; - final IStackSrc src; - - public DamagedItemDefinition(IStackSrc is) { - this.src = is; + public DamagedItemDefinition( IStackSrc source ) + { + this.source = source; } @Override - public Block block() + public Optional maybeItem() { - return null; + final Item item = this.source.getItem(); + + return Optional.fromNullable( item ); } @Override - public Item item() + public Optional maybeStack( int stackSize ) { - return this.src.getItem(); + final ItemStack stack = this.source.stack( stackSize ); + + return Optional.fromNullable( stack ); } @Override - public Class entity() + public boolean isSameAs( ItemStack comparableStack ) { - return null; - } - - @Override - public ItemStack stack(int stackSize) - { - return this.src.stack( stackSize ); - } - - @Override - public boolean sameAsStack(ItemStack comparableItem) - { - if ( comparableItem == null ) + if ( comparableStack == null ) return false; - return comparableItem.getItem() == this.src.getItem() && comparableItem.getItemDamage() == this.src.getDamage(); + return comparableStack.getItem() == this.source.getItem() && comparableStack.getItemDamage() == this.source.getDamage(); } @Override - public boolean sameAsBlock(IBlockAccess world, int x, int y, int z) + public boolean isSameAs( IBlockAccess world, int x, int y, int z ) { return false; } - } diff --git a/src/main/java/appeng/core/features/DefinitionConverter.java b/src/main/java/appeng/core/features/DefinitionConverter.java new file mode 100644 index 000000000..9b8821f23 --- /dev/null +++ b/src/main/java/appeng/core/features/DefinitionConverter.java @@ -0,0 +1,160 @@ +package appeng.core.features; + + +import javax.annotation.Nullable; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; + +import appeng.api.definitions.IBlockDefinition; +import appeng.api.definitions.IComparableDefinition; +import appeng.api.definitions.IItemDefinition; +import appeng.api.definitions.ITileDefinition; +import appeng.api.util.AEItemDefinition; + + +/** + * @deprecated + */ +@Deprecated +public final class DefinitionConverter +{ + public AEItemDefinition of( ITileDefinition definition ) + { + return new AETile( definition ); + } + + public AEItemDefinition of( IBlockDefinition definition ) + { + return new AEBlock( definition ); + } + + public AEItemDefinition of( IItemDefinition definition ) + { + return new AEItem( definition ); + } + + public AEItemDefinition of( IComparableDefinition definition ) + { + return new AEComparable( definition ); + } + + private static class AEComparable implements AEItemDefinition + { + private final IComparableDefinition definition; + + public AEComparable( IComparableDefinition definition ) + { + this.definition = definition; + } + + @Nullable + @Override + public Block block() + { + return null; + } + + @Nullable + @Override + public Item item() + { + return null; + } + + @Nullable + @Override + public Class entity() + { + return null; + } + + @Nullable + @Override + public ItemStack stack( int stackSize ) + { + return null; + } + + @Override + public boolean sameAsStack( ItemStack comparableItem ) + { + return this.definition.isSameAs( comparableItem ); + } + + @Override + public boolean sameAsBlock( IBlockAccess world, int x, int y, int z ) + { + return this.definition.isSameAs( world, x, y, z ); + } + } + + private static class AEItem extends AEComparable + { + private final IItemDefinition definition; + + public AEItem( IItemDefinition definition ) + { + super( definition ); + + this.definition = definition; + } + + @Nullable + @Override + public ItemStack stack( int stackSize ) + { + return this.definition.maybeStack( stackSize ).orNull(); + } + + @Nullable + @Override + public Item item() + { + return this.definition.maybeItem().orNull(); + } + } + + private static class AEBlock extends AEItem + { + private final IBlockDefinition definition; + + public AEBlock( IBlockDefinition definition ) + { + super( definition ); + + this.definition = definition; + } + + @Nullable + @Override + public Block block() + { + return this.definition.maybeBlock().orNull(); + } + } + + private static class AETile extends AEBlock + { + private final ITileDefinition definition; + + public AETile( ITileDefinition definition ) + { + super( definition ); + + this.definition = definition; + } + + @Nullable + @Override + public Class entity() + { + return this.definition.maybeEntity().orNull(); + } + } + + +} diff --git a/src/main/java/appeng/core/features/FeaturedActiveChecker.java b/src/main/java/appeng/core/features/FeaturedActiveChecker.java index f85c0c543..001961505 100644 --- a/src/main/java/appeng/core/features/FeaturedActiveChecker.java +++ b/src/main/java/appeng/core/features/FeaturedActiveChecker.java @@ -19,30 +19,30 @@ package appeng.core.features; -import java.util.EnumSet; +import java.util.Set; import appeng.core.AEConfig; public class FeaturedActiveChecker { - private final EnumSet features; + private final Set features; - public FeaturedActiveChecker( EnumSet features ) + public FeaturedActiveChecker( Set features ) { this.features = features; } - public boolean get() + public ActivityState getActivityState() { for ( AEFeature f : this.features ) { if ( !AEConfig.instance.isFeatureEnabled( f ) ) { - return false; + return ActivityState.Disabled; } } - return true; + return ActivityState.Enabled; } } diff --git a/src/main/java/appeng/core/features/IFeatureHandler.java b/src/main/java/appeng/core/features/IFeatureHandler.java index ae0ae042d..de16fc2ef 100644 --- a/src/main/java/appeng/core/features/IFeatureHandler.java +++ b/src/main/java/appeng/core/features/IFeatureHandler.java @@ -19,18 +19,14 @@ package appeng.core.features; -import java.util.EnumSet; - -import appeng.api.util.AEItemDefinition; +import appeng.api.definitions.IItemDefinition; public interface IFeatureHandler { boolean isFeatureAvailable(); - EnumSet getFeatures(); - - AEItemDefinition getDefinition(); + IItemDefinition getDefinition(); void register(); } diff --git a/src/main/java/appeng/core/features/ItemDefinition.java b/src/main/java/appeng/core/features/ItemDefinition.java index 31dad13d7..2162b7994 100644 --- a/src/main/java/appeng/core/features/ItemDefinition.java +++ b/src/main/java/appeng/core/features/ItemDefinition.java @@ -19,66 +19,54 @@ package appeng.core.features; -import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; -import appeng.api.util.AEItemDefinition; +import com.google.common.base.Optional; + +import appeng.api.definitions.IItemDefinition; import appeng.util.Platform; -public class ItemDefinition implements AEItemDefinition +public class ItemDefinition implements IItemDefinition { private final Item item; private final boolean enabled; - public ItemDefinition( Item item, boolean enabled ) + public ItemDefinition( Item item, ActivityState state ) { this.item = item; - this.enabled = enabled; + this.enabled = state == ActivityState.Enabled; } @Override - public Block block() + public final Optional maybeItem() { - return null; + return Optional.of( this.item ); } @Override - public Item item() - { - return this.item; - } - - @Override - public Class entity() - { - return null; - } - - @Override - public ItemStack stack( int stackSize ) + public Optional maybeStack( int stackSize ) { if ( this.enabled ) { - return new ItemStack( this.item ); + return Optional.of( new ItemStack( this.item ) ); } else { - return null; + return Optional.absent(); } } @Override - public boolean sameAsStack( ItemStack comparableItem ) + public final boolean isSameAs( ItemStack comparableStack ) { - return this.enabled && Platform.isSameItemType( comparableItem, this.stack( 1 ) ); + return this.enabled && Platform.isSameItemType( comparableStack, this.maybeStack( 1 ).get() ); } @Override - public boolean sameAsBlock( IBlockAccess world, int x, int y, int z ) + public boolean isSameAs( IBlockAccess world, int x, int y, int z ) { return false; } diff --git a/src/main/java/appeng/core/features/ItemFeatureHandler.java b/src/main/java/appeng/core/features/ItemFeatureHandler.java index ac27ce0ad..1739bc4dc 100644 --- a/src/main/java/appeng/core/features/ItemFeatureHandler.java +++ b/src/main/java/appeng/core/features/ItemFeatureHandler.java @@ -21,21 +21,20 @@ package appeng.core.features; import java.util.EnumSet; -import com.google.common.base.Optional; - import net.minecraft.item.Item; import cpw.mods.fml.common.registry.GameRegistry; -import appeng.api.util.AEItemDefinition; +import com.google.common.base.Optional; + +import appeng.api.definitions.IItemDefinition; import appeng.core.CreativeTab; import appeng.core.CreativeTabFacade; import appeng.items.parts.ItemFacade; -public class ItemFeatureHandler implements IFeatureHandler +public final class ItemFeatureHandler implements IFeatureHandler { - private final EnumSet features; private final Item item; private final FeatureNameExtractor extractor; private final boolean enabled; @@ -43,11 +42,12 @@ public class ItemFeatureHandler implements IFeatureHandler public ItemFeatureHandler( EnumSet features, Item item, IAEFeature featured, Optional subName ) { - this.features = features; + final ActivityState state = new FeaturedActiveChecker( features ).getActivityState(); + this.item = item; this.extractor = new FeatureNameExtractor( featured.getClass(), subName ); - this.enabled = new FeaturedActiveChecker( features ).get(); - this.definition = new ItemDefinition( item, this.enabled ); + this.enabled = state == ActivityState.Enabled; + this.definition = new ItemDefinition( item, state ); } @Override @@ -57,13 +57,7 @@ public class ItemFeatureHandler implements IFeatureHandler } @Override - public EnumSet getFeatures() - { - return this.features; - } - - @Override - public AEItemDefinition getDefinition() + public IItemDefinition getDefinition() { return this.definition; } @@ -71,28 +65,31 @@ public class ItemFeatureHandler implements IFeatureHandler @Override public void register() { - String name = this.extractor.get(); - this.item.setTextureName( "appliedenergistics2:" + name ); - this.item.setUnlocalizedName( /* "item." */"appliedenergistics2." + name ); + if ( this.enabled ) + { + String name = this.extractor.get(); + this.item.setTextureName( "appliedenergistics2:" + name ); + this.item.setUnlocalizedName( /* "item." */"appliedenergistics2." + name ); - if ( this.item instanceof ItemFacade ) - { - this.item.setCreativeTab( CreativeTabFacade.instance ); - } - else - { - this.item.setCreativeTab( CreativeTab.instance ); - } + if ( this.item instanceof ItemFacade ) + { + this.item.setCreativeTab( CreativeTabFacade.instance ); + } + else + { + this.item.setCreativeTab( CreativeTab.instance ); + } - if ( name.equals( "ItemMaterial" ) ) - { - name = "ItemMultiMaterial"; - } - else if ( name.equals( "ItemPart" ) ) - { - name = "ItemMultiPart"; - } + if ( name.equals( "ItemMaterial" ) ) + { + name = "ItemMultiMaterial"; + } + else if ( name.equals( "ItemPart" ) ) + { + name = "ItemMultiPart"; + } - GameRegistry.registerItem( this.item, "item." + name ); + GameRegistry.registerItem( this.item, "item." + name ); + } } } diff --git a/src/main/java/appeng/core/features/MaterialStackSrc.java b/src/main/java/appeng/core/features/MaterialStackSrc.java index bef22f77f..9b4ee560e 100644 --- a/src/main/java/appeng/core/features/MaterialStackSrc.java +++ b/src/main/java/appeng/core/features/MaterialStackSrc.java @@ -18,24 +18,27 @@ package appeng.core.features; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import appeng.items.materials.MaterialType; + public class MaterialStackSrc implements IStackSrc { final MaterialType src; - public MaterialStackSrc(MaterialType src) { + public MaterialStackSrc( MaterialType src ) + { + assert src != null; + this.src = src; - if ( src == null ) - throw new RuntimeException( "Invalid Item Stack" ); } @Override - public ItemStack stack(int stackSize) + public ItemStack stack( int stackSize ) { return this.src.stack( stackSize ); } @@ -51,5 +54,4 @@ public class MaterialStackSrc implements IStackSrc { return this.src.damageValue; } - } diff --git a/src/main/java/appeng/core/features/NameResolver.java b/src/main/java/appeng/core/features/NameResolver.java new file mode 100644 index 000000000..84e6ad865 --- /dev/null +++ b/src/main/java/appeng/core/features/NameResolver.java @@ -0,0 +1,75 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.core.features; + + +import java.util.regex.Pattern; + +import appeng.items.AEBaseItem; + + +/** + * This class is used to rename items to match the persistent stored items. + * + * This can be removed, when a new iteration of minecraft arrives or a new world is used. + * Remember to differentiate the currently renamed items later on correctly. + * + * @deprecated only a temporary solution for a rename + */ +@Deprecated +public final class NameResolver +{ + private static final Pattern ITEM_MULTI_PART = Pattern.compile( "ItemMultiPart", Pattern.LITERAL ); + private static final Pattern ITEM_MULTI_MATERIAL = Pattern.compile( "ItemMultiMaterial", Pattern.LITERAL ); + private static final Pattern QUARTZ = Pattern.compile( "Quartz", Pattern.LITERAL ); + + private final Class withOriginalName; + + public NameResolver( Class withOriginalName) + { + this.withOriginalName = withOriginalName; + } + + public String getName( String subName ) + { + String name = this.withOriginalName.getSimpleName(); + + if ( name.startsWith( "ItemMultiPart" ) ) + name = ITEM_MULTI_PART.matcher( name ).replaceAll( "ItemPart" ); + else if ( name.startsWith( "ItemMultiMaterial" ) ) + name = ITEM_MULTI_MATERIAL.matcher( name ).replaceAll( "ItemMaterial" ); + + if ( subName != null ) + { + // simple hack to allow me to do get nice names for these without + // mode code outside of AEBaseItem + if ( subName.startsWith( "P2PTunnel" ) ) + return "ItemPart.P2PTunnel"; + + if ( subName.equals( "CertusQuartzTools" ) ) + return QUARTZ.matcher( name ).replaceAll( "CertusQuartz" ); + if ( subName.equals( "NetherQuartzTools" ) ) + return QUARTZ.matcher( name ).replaceAll( "NetherQuartz" ); + + name += '.' + subName; + } + + return name; + } +} diff --git a/src/main/java/appeng/core/features/NullItemDefinition.java b/src/main/java/appeng/core/features/NullItemDefinition.java deleted file mode 100644 index 24fcd5917..000000000 --- a/src/main/java/appeng/core/features/NullItemDefinition.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. - * - * Applied Energistics 2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Applied Energistics 2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Applied Energistics 2. If not, see . - */ - -package appeng.core.features; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; - -import appeng.api.util.AEItemDefinition; - -public class NullItemDefinition implements AEItemDefinition -{ - - @Override - public Block block() - { - return null; - } - - @Override - public Item item() - { - return null; - } - - @Override - public Class entity() - { - return null; - } - - @Override - public ItemStack stack(int stackSize) - { - return null; - } - - @Override - public boolean sameAsStack(ItemStack comparableItem) - { - return false; - } - - @Override - public boolean sameAsBlock(IBlockAccess world, int x, int y, int z) - { - return false; - } - -} diff --git a/src/main/java/appeng/core/features/StairBlockFeatureHandler.java b/src/main/java/appeng/core/features/StairBlockFeatureHandler.java index cc74dc907..cedc4b111 100644 --- a/src/main/java/appeng/core/features/StairBlockFeatureHandler.java +++ b/src/main/java/appeng/core/features/StairBlockFeatureHandler.java @@ -21,19 +21,18 @@ package appeng.core.features; import java.util.EnumSet; -import com.google.common.base.Optional; - import net.minecraft.block.BlockStairs; import cpw.mods.fml.common.registry.GameRegistry; -import appeng.api.util.AEItemDefinition; +import com.google.common.base.Optional; + +import appeng.api.definitions.IBlockDefinition; import appeng.core.CreativeTab; public class StairBlockFeatureHandler implements IFeatureHandler { - private final EnumSet features; private final BlockStairs stairs; private final FeatureNameExtractor extractor; private final boolean enabled; @@ -41,39 +40,37 @@ public class StairBlockFeatureHandler implements IFeatureHandler public StairBlockFeatureHandler( EnumSet features, BlockStairs stairs, Optional subName ) { - this.features = features; + final ActivityState state = new FeaturedActiveChecker( features ).getActivityState(); + this.stairs = stairs; this.extractor = new FeatureNameExtractor( stairs.getClass(), subName ); - this.enabled = new FeaturedActiveChecker( features ).get(); - this.definition = new BlockDefinition( stairs, this.enabled ); + this.enabled = state == ActivityState.Enabled; + this.definition = new BlockDefinition( stairs, state ); } @Override - public boolean isFeatureAvailable() + public final boolean isFeatureAvailable() { return this.enabled; } @Override - public EnumSet getFeatures() - { - return this.features; - } - - @Override - public AEItemDefinition getDefinition() + public final IBlockDefinition getDefinition() { return this.definition; } @Override - public void register() + public final void register() { - String name = this.extractor.get(); - this.stairs.setCreativeTab( CreativeTab.instance ); - this.stairs.setBlockName( "appliedenergistics2." + name ); - this.stairs.setBlockTextureName( "appliedenergistics2:" + name ); + if ( this.enabled ) + { + String name = this.extractor.get(); + this.stairs.setCreativeTab( CreativeTab.instance ); + this.stairs.setBlockName( "appliedenergistics2." + name ); + this.stairs.setBlockTextureName( "appliedenergistics2:" + name ); - GameRegistry.registerBlock( this.stairs, "tile." + name ); + GameRegistry.registerBlock( this.stairs, "tile." + name ); + } } } diff --git a/src/main/java/appeng/core/features/AEBlockDefinition.java b/src/main/java/appeng/core/features/TileDefinition.java similarity index 69% rename from src/main/java/appeng/core/features/AEBlockDefinition.java rename to src/main/java/appeng/core/features/TileDefinition.java index fd00804b7..fcd573d99 100644 --- a/src/main/java/appeng/core/features/AEBlockDefinition.java +++ b/src/main/java/appeng/core/features/TileDefinition.java @@ -21,23 +21,28 @@ package appeng.core.features; import net.minecraft.tileentity.TileEntity; +import com.google.common.base.Optional; + +import appeng.api.definitions.ITileDefinition; import appeng.block.AEBaseBlock; -public class AEBlockDefinition extends BlockDefinition +public final class TileDefinition extends BlockDefinition implements ITileDefinition { private final AEBaseBlock block; - public AEBlockDefinition( AEBaseBlock block, boolean enabled ) + public TileDefinition( AEBaseBlock block, ActivityState state ) { - super( block, enabled ); + super( block, state ); this.block = block; } @Override - public Class entity() + public Optional> maybeEntity() { - return this.block.getTileEntityClass(); + final Class entity = this.block.getTileEntityClass(); + + return Optional.of( entity ); } } diff --git a/src/main/java/appeng/core/features/WrappedDamageItemDefinition.java b/src/main/java/appeng/core/features/WrappedDamageItemDefinition.java index b6722b832..73410b789 100644 --- a/src/main/java/appeng/core/features/WrappedDamageItemDefinition.java +++ b/src/main/java/appeng/core/features/WrappedDamageItemDefinition.java @@ -18,67 +18,92 @@ package appeng.core.features; + +import javax.annotation.Nullable; + import net.minecraft.block.Block; import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; -import appeng.api.util.AEItemDefinition; +import com.google.common.base.Function; +import com.google.common.base.Optional; -public class WrappedDamageItemDefinition implements AEItemDefinition +import appeng.api.definitions.ITileDefinition; + + +public final class WrappedDamageItemDefinition implements ITileDefinition { + private final ITileDefinition definition; + private final int damage; - final AEItemDefinition baseItem; - final int damage; - - public WrappedDamageItemDefinition(AEItemDefinition def, int dmg) { - this.baseItem = def; - this.damage = dmg; + public WrappedDamageItemDefinition( ITileDefinition definition, int damage ) + { + this.definition = definition; + this.damage = damage; } @Override - public Block block() + public Optional> maybeEntity() { - return this.baseItem.block(); + return this.definition.maybeEntity(); } @Override - public Item item() + public Optional maybeBlock() { - return this.baseItem.item(); + return this.definition.maybeBlock(); } @Override - public Class entity() + public Optional maybeItemBlock() { - return this.baseItem.entity(); + return this.definition.maybeItemBlock(); } @Override - public ItemStack stack(int stackSize) + public Optional maybeItem() { - if ( this.baseItem == null ) - return null; - - return new ItemStack( this.baseItem.block(), stackSize, this.damage ); + return this.definition.maybeItem(); } @Override - public boolean sameAsStack(ItemStack comparableItem) + public Optional maybeStack( final int stackSize ) { - if ( comparableItem == null ) + return this.definition.maybeBlock().transform( new BlockTransformFunction( stackSize ) ); + } + + @Override + public boolean isSameAs( ItemStack comparableStack ) + { + if ( comparableStack == null ) return false; - return comparableItem.getItem() == this.baseItem.item() && comparableItem.getItemDamage() == this.damage; + return this.definition.isSameAs( comparableStack ) && comparableStack.getItemDamage() == this.damage; } @Override - public boolean sameAsBlock(IBlockAccess world, int x, int y, int z) + public boolean isSameAs( IBlockAccess world, int x, int y, int z ) { - if ( this.block() != null ) - return world.getBlock( x, y, z ) == this.block() && world.getBlockMetadata( x, y, z ) == this.damage; - return false; + return this.definition.isSameAs( world, x, y, z ) && world.getBlockMetadata( x, y, z ) == this.damage; } + private class BlockTransformFunction implements Function + { + private final int stackSize; + + public BlockTransformFunction( int stackSize ) + { + this.stackSize = stackSize; + } + + @Nullable + @Override + public ItemStack apply( Block input ) + { + return new ItemStack( input, this.stackSize, WrappedDamageItemDefinition.this.damage ); + } + } } diff --git a/src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java b/src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java index 1d6e7c96e..6ea7bd279 100644 --- a/src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java +++ b/src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java @@ -30,7 +30,10 @@ import cpw.mods.fml.common.registry.GameRegistry; import appeng.api.AEApi; import appeng.api.config.TunnelType; -import appeng.api.definitions.Parts; +import appeng.api.definitions.IBlocks; +import appeng.api.definitions.IDefinitions; +import appeng.api.definitions.IItemDefinition; +import appeng.api.definitions.IParts; import appeng.api.features.IP2PTunnelRegistry; import appeng.api.util.AEColor; import appeng.util.Platform; @@ -78,14 +81,16 @@ public class P2PTunnelRegistry implements IP2PTunnelRegistry /** * attune based on lots of random item related stuff */ - appeng.api.definitions.Blocks AEBlocks = AEApi.instance().blocks(); - Parts Parts = AEApi.instance().parts(); + final IDefinitions definitions = AEApi.instance().definitions(); + final IBlocks blocks = definitions.blocks(); + final IParts parts = definitions.parts(); + + this.addNewAttunement( blocks.iface(), TunnelType.ITEM ); + this.addNewAttunement( parts.iface(), TunnelType.ITEM ); + this.addNewAttunement( parts.storageBus(), TunnelType.ITEM ); + this.addNewAttunement( parts.importBus(), TunnelType.ITEM ); + this.addNewAttunement( parts.exportBus(), TunnelType.ITEM ); - this.addNewAttunement( AEBlocks.blockInterface.stack( 1 ), TunnelType.ITEM ); - this.addNewAttunement( Parts.partInterface.stack( 1 ), TunnelType.ITEM ); - this.addNewAttunement( Parts.partStorageBus.stack( 1 ), TunnelType.ITEM ); - this.addNewAttunement( Parts.partImportBus.stack( 1 ), TunnelType.ITEM ); - this.addNewAttunement( Parts.partExportBus.stack( 1 ), TunnelType.ITEM ); this.addNewAttunement( new ItemStack( Blocks.hopper ), TunnelType.ITEM ); this.addNewAttunement( new ItemStack( Blocks.chest ), TunnelType.ITEM ); this.addNewAttunement( new ItemStack( Blocks.trapped_chest ), TunnelType.ITEM ); @@ -108,10 +113,18 @@ public class P2PTunnelRegistry implements IP2PTunnelRegistry for (AEColor c : AEColor.values()) { - this.addNewAttunement( Parts.partCableGlass.stack( c, 1 ), TunnelType.ME ); - this.addNewAttunement( Parts.partCableCovered.stack( c, 1 ), TunnelType.ME ); - this.addNewAttunement( Parts.partCableSmart.stack( c, 1 ), TunnelType.ME ); - this.addNewAttunement( Parts.partCableDense.stack( c, 1 ), TunnelType.ME ); + this.addNewAttunement( parts.cableGlass().stack( c, 1 ), TunnelType.ME ); + this.addNewAttunement( parts.cableCovered().stack( c, 1 ), TunnelType.ME ); + this.addNewAttunement( parts.cableSmart().stack( c, 1 ), TunnelType.ME ); + this.addNewAttunement( parts.cableDense().stack( c, 1 ), TunnelType.ME ); + } + } + + private void addNewAttunement( IItemDefinition definition, TunnelType type ) + { + for ( ItemStack definitionStack : definition.maybeStack( 1 ).asSet() ) + { + this.addNewAttunement( definitionStack, type ); } } diff --git a/src/main/java/appeng/core/stats/Achievements.java b/src/main/java/appeng/core/stats/Achievements.java index 3433c0ccf..2159c2d8a 100644 --- a/src/main/java/appeng/core/stats/Achievements.java +++ b/src/main/java/appeng/core/stats/Achievements.java @@ -24,88 +24,87 @@ import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; import appeng.api.AEApi; +import appeng.api.definitions.IItemDefinition; import appeng.api.util.AEColor; import appeng.api.util.AEColoredItemDefinition; -import appeng.api.util.AEItemDefinition; public enum Achievements { + // done + Compass( -2, -4, AEApi.instance().definitions().blocks().skyCompass(), AchievementType.Craft ), // done - Compass( -2, -4, AEApi.instance().blocks().blockSkyCompass, AchievementType.Craft ), + Presses( -2, -2, AEApi.instance().definitions().materials().logicProcessorPress(), AchievementType.Custom ), // done - Presses( -2, -2, AEApi.instance().materials().materialLogicProcessorPress, AchievementType.Custom ), + SpatialIO( -4, -4, AEApi.instance().definitions().blocks().spatialIOPort(), AchievementType.Craft ), // done - SpatialIO( -4, -4, AEApi.instance().blocks().blockSpatialIOPort, AchievementType.Craft ), + SpatialIOExplorer( -4, -2, AEApi.instance().definitions().items().spatialCell128(), AchievementType.Custom ), // done - SpatialIOExplorer( -4, -2, AEApi.instance().items().itemSpatialCell128, AchievementType.Custom ), + StorageCell( -6, -4, AEApi.instance().definitions().items().cell64k(), AchievementType.CraftItem ), // done - StorageCell( -6, -4, AEApi.instance().items().itemCell64k, AchievementType.CraftItem ), + IOPort( -6, -2, AEApi.instance().definitions().blocks().iOPort(), AchievementType.Craft ), // done - IOPort( -6, -2, AEApi.instance().blocks().blockIOPort, AchievementType.Craft ), + CraftingTerminal( -8, -4, AEApi.instance().definitions().parts().craftingTerminal(), AchievementType.Craft ), // done - CraftingTerminal( -8, -4, AEApi.instance().parts().partCraftingTerminal, AchievementType.Craft ), + PatternTerminal( -8, -2, AEApi.instance().definitions().parts().patternTerminal(), AchievementType.Craft ), // done - PatternTerminal( -8, -2, AEApi.instance().parts().partPatternTerminal, AchievementType.Craft ), + ChargedQuartz( 0, -4, AEApi.instance().definitions().materials().certusQuartzCrystalCharged(), AchievementType.Pickup ), // done - ChargedQuartz( 0, -4, AEApi.instance().materials().materialCertusQuartzCrystalCharged, AchievementType.Pickup ), + Fluix( 0, -2, AEApi.instance().definitions().materials().fluixCrystal(), AchievementType.Pickup ), // done - Fluix( 0, -2, AEApi.instance().materials().materialFluixCrystal, AchievementType.Pickup ), + Charger( 0, 0, AEApi.instance().definitions().blocks().charger(), AchievementType.Craft ), // done - Charger( 0, 0, AEApi.instance().blocks().blockCharger, AchievementType.Craft ), + CrystalGrowthAccelerator( -2, 0, AEApi.instance().definitions().blocks().quartzGrowthAccelerator(), AchievementType.Craft ), // done - CrystalGrowthAccelerator( -2, 0, AEApi.instance().blocks().blockQuartzGrowthAccelerator, AchievementType.Craft ), + GlassCable( 2, 0, AEApi.instance().definitions().parts().cableGlass(), AchievementType.Craft ), // done - GlassCable( 2, 0, AEApi.instance().parts().partCableGlass, AchievementType.Craft ), + Networking1( 4, -6, AEApi.instance().definitions().parts().cableCovered(), AchievementType.Custom ), // done - Networking1( 4, -6, AEApi.instance().parts().partCableCovered, AchievementType.Custom ), + Controller( 4, -4, AEApi.instance().definitions().blocks().controller(), AchievementType.Craft ), // done - Controller( 4, -4, AEApi.instance().blocks().blockController, AchievementType.Craft ), + Networking2( 4, 0, AEApi.instance().definitions().parts().cableSmart(), AchievementType.Custom ), // done - Networking2( 4, 0, AEApi.instance().parts().partCableSmart, AchievementType.Custom ), + Networking3( 4, 2, AEApi.instance().definitions().parts().cableDense(), AchievementType.Custom ), // done - Networking3( 4, 2, AEApi.instance().parts().partCableDense, AchievementType.Custom ), + P2P( 2, -2, AEApi.instance().definitions().parts().p2PTunnelME(), AchievementType.Craft ), // done - P2P( 2, -2, AEApi.instance().parts().partP2PTunnelME, AchievementType.Craft ), + Recursive( 6, -2, AEApi.instance().definitions().blocks().iface(), AchievementType.Craft ), // done - Recursive( 6, -2, AEApi.instance().blocks().blockInterface, AchievementType.Craft ), + CraftingCPU( 6, 0, AEApi.instance().definitions().blocks().craftingStorage64k(), AchievementType.CraftItem ), // done - CraftingCPU( 6, 0, AEApi.instance().blocks().blockCraftingStorage64k, AchievementType.CraftItem ), + Facade( 6, 2, AEApi.instance().definitions().items().facade(), AchievementType.CraftItem ), // done - Facade( 6, 2, AEApi.instance().items().itemFacade, AchievementType.CraftItem ), + NetworkTool( 8, 0, AEApi.instance().definitions().items().networkTool(), AchievementType.Craft ), // done - NetworkTool( 8, 0, AEApi.instance().items().itemNetworkTool, AchievementType.Craft ), + PortableCell( 8, 2, AEApi.instance().definitions().items().portableCell(), AchievementType.Craft ), // done - PortableCell( 8, 2, AEApi.instance().items().itemPortableCell, AchievementType.Craft ), + StorageBus( 10, 0, AEApi.instance().definitions().parts().storageBus(), AchievementType.Craft ), // done - StorageBus( 10, 0, AEApi.instance().parts().partStorageBus, AchievementType.Craft ), - - // done - QNB( 10, 2, AEApi.instance().blocks().blockQuantumLink, AchievementType.Craft ); + QNB( 10, 2, AEApi.instance().definitions().blocks().quantumLink(), AchievementType.Craft ); public final ItemStack stack; public final AchievementType type; @@ -139,9 +138,9 @@ public enum Achievements this.y = y; } - Achievements( int x, int y, AEItemDefinition which, AchievementType type ) + Achievements( int x, int y, IItemDefinition which, AchievementType type ) { - this.stack = (which != null) ? which.stack( 1 ) : null; + this.stack = which.maybeStack( 1 ).orNull(); this.type = type; this.x = x; this.y = y; diff --git a/src/main/java/appeng/core/sync/GuiBridge.java b/src/main/java/appeng/core/sync/GuiBridge.java index e108bf69e..927b3d394 100644 --- a/src/main/java/appeng/core/sync/GuiBridge.java +++ b/src/main/java/appeng/core/sync/GuiBridge.java @@ -20,6 +20,7 @@ package appeng.core.sync; import java.lang.reflect.Constructor; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -32,9 +33,12 @@ import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.relauncher.ReflectionHelper; +import com.google.common.collect.Lists; + import appeng.api.AEApi; import appeng.api.config.SecurityPermissions; -import appeng.api.definitions.Materials; +import appeng.api.definitions.IComparableDefinition; +import appeng.api.definitions.IMaterials; import appeng.api.exceptions.AppEngException; import appeng.api.features.IWirelessTermHandler; import appeng.api.implementations.IUpgradeableHost; @@ -273,12 +277,8 @@ public enum GuiBridge implements IGuiHandler { ItemStack is = ((Slot) so).getStack(); - Materials m = AEApi.instance().materials(); - if ( m.materialLogicProcessorPress.sameAsStack( is ) || m.materialEngProcessorPress.sameAsStack( is ) - || m.materialCalcProcessorPress.sameAsStack( is ) || m.materialSiliconPress.sameAsStack( is ) ) - { - Achievements.Presses.addToPlayer( inventory.player ); - } + final IMaterials materials = AEApi.instance().definitions().materials(); + this.addPressAchievementToPlayer( is, materials, inventory.player ); } } } @@ -291,6 +291,26 @@ public enum GuiBridge implements IGuiHandler } } + private void addPressAchievementToPlayer( ItemStack newItem, IMaterials possibleMaterials, EntityPlayer player ) + { + final IComparableDefinition logic = possibleMaterials.logicProcessorPress(); + final IComparableDefinition eng = possibleMaterials.engProcessorPress(); + final IComparableDefinition calc = possibleMaterials.calcProcessorPress(); + final IComparableDefinition silicon = possibleMaterials.siliconPress(); + + final List presses = Lists.newArrayList( logic, eng, calc, silicon ); + + for ( IComparableDefinition press : presses ) + { + if ( press.isSameAs( newItem ) ) + { + Achievements.Presses.addToPlayer( player ); + + return; + } + } + } + public Object ConstructGui(InventoryPlayer inventory, ForgeDirection side, Object tE) { try diff --git a/src/main/java/appeng/core/sync/packets/PacketClick.java b/src/main/java/appeng/core/sync/packets/PacketClick.java index e3bae0a84..f3abfbc1a 100644 --- a/src/main/java/appeng/core/sync/packets/PacketClick.java +++ b/src/main/java/appeng/core/sync/packets/PacketClick.java @@ -25,6 +25,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import appeng.api.AEApi; +import appeng.api.definitions.IComparableDefinition; +import appeng.api.definitions.IItems; import appeng.api.implementations.items.IMemoryCard; import appeng.api.implementations.items.MemoryCardMessages; import appeng.core.sync.AppEngPacket; @@ -58,21 +60,30 @@ public class PacketClick extends AppEngPacket public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player) { ItemStack is = player.inventory.getCurrentItem(); - if ( is != null && is.getItem() instanceof ToolNetworkTool ) + final IItems items = AEApi.instance().definitions().items(); + final IComparableDefinition maybeMemoryCard = items.memoryCard(); + final IComparableDefinition maybeColorApplicator = items.colorApplicator(); + + if ( is != null ) { - ToolNetworkTool tnt = (ToolNetworkTool) is.getItem(); - tnt.serverSideToolLogic( is, player, player.worldObj, this.x, this.y, this.z, this.side, this.hitX, this.hitY, this.hitZ ); - } - else if ( is != null && AEApi.instance().items().itemMemoryCard.sameAsStack( is ) ) - { - IMemoryCard mem = (IMemoryCard) is.getItem(); - mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED ); - is.setTagCompound( null ); - } - else if ( is != null && AEApi.instance().items().itemColorApplicator.sameAsStack( is ) ) - { - ToolColorApplicator mem = (ToolColorApplicator) is.getItem(); - mem.cycleColors( is, mem.getColor( is ), 1 ); + if ( is.getItem() instanceof ToolNetworkTool ) + { + ToolNetworkTool tnt = (ToolNetworkTool) is.getItem(); + tnt.serverSideToolLogic( is, player, player.worldObj, this.x, this.y, this.z, this.side, this.hitX, this.hitY, this.hitZ ); + } + + else if ( maybeMemoryCard.isSameAs( is ) ) + { + IMemoryCard mem = (IMemoryCard) is.getItem(); + mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED ); + is.setTagCompound( null ); + } + + else if ( maybeColorApplicator.isSameAs( is ) ) + { + ToolColorApplicator mem = (ToolColorApplicator) is.getItem(); + mem.cycleColors( is, mem.getColor( is ), 1 ); + } } } diff --git a/src/main/java/appeng/core/sync/packets/PacketValueConfig.java b/src/main/java/appeng/core/sync/packets/PacketValueConfig.java index 5030e5ac2..8d1378c3c 100644 --- a/src/main/java/appeng/core/sync/packets/PacketValueConfig.java +++ b/src/main/java/appeng/core/sync/packets/PacketValueConfig.java @@ -34,6 +34,7 @@ import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import appeng.api.config.FuzzyMode; +import appeng.api.config.Settings; import appeng.api.util.IConfigManager; import appeng.api.util.IConfigurableObject; import appeng.client.gui.implementations.GuiCraftingCPU; @@ -183,11 +184,11 @@ public class PacketValueConfig extends AppEngPacket { IConfigManager cm = ((IConfigurableObject) c).getConfigManager(); - for (Enum e : cm.getSettings()) + for (Settings e : cm.getSettings()) { if ( e.name().equals( this.Name ) ) { - Enum def = cm.getSetting( e ); + Enum def = cm.getSetting( e ); try { @@ -228,11 +229,11 @@ public class PacketValueConfig extends AppEngPacket { IConfigManager cm = ((IConfigurableObject) c).getConfigManager(); - for (Enum e : cm.getSettings()) + for (Settings e : cm.getSettings()) { if ( e.name().equals( this.Name ) ) { - Enum def = cm.getSetting( e ); + Enum def = cm.getSetting( e ); try { diff --git a/src/main/java/appeng/debug/ToolDebugCard.java b/src/main/java/appeng/debug/ToolDebugCard.java index e4cb01b9a..195280845 100644 --- a/src/main/java/appeng/debug/ToolDebugCard.java +++ b/src/main/java/appeng/debug/ToolDebugCard.java @@ -18,9 +18,12 @@ package appeng.debug; + import java.util.EnumSet; import java.util.HashSet; +import java.util.Set; +import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -48,24 +51,16 @@ import appeng.parts.p2p.PartP2PTunnel; import appeng.tile.networking.TileController; import appeng.util.Platform; + public class ToolDebugCard extends AEBaseItem { - - public ToolDebugCard() { - super( ToolDebugCard.class ); + public ToolDebugCard() + { this.setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) ); } - public String timeMeasurement(long nanos) - { - long ms = nanos / 100000; - if ( nanos <= 100000 ) - return nanos + "ns"; - return (ms / 10.0f) + "ms"; - } - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ ) { if ( Platform.isClient() ) return false; @@ -75,7 +70,7 @@ public class ToolDebugCard extends AEBaseItem int grids = 0; int totalNodes = 0; - for (Grid g : TickHandler.INSTANCE.getGridList()) + for ( Grid g : TickHandler.INSTANCE.getGridList() ) { grids++; totalNodes += g.getNodes().size(); @@ -90,7 +85,7 @@ public class ToolDebugCard extends AEBaseItem if ( te instanceof IGridHost ) { - GridNode node = (GridNode) ((IGridHost) te).getGridNode( ForgeDirection.getOrientation( side ) ); + GridNode node = (GridNode) ( (IGridHost) te ).getGridNode( ForgeDirection.getOrientation( side ) ); if ( node != null ) { Grid g = node.getInternalGrid(); @@ -103,14 +98,15 @@ public class ToolDebugCard extends AEBaseItem { int length = 0; - HashSet next = new HashSet(); + Set next = new HashSet(); next.add( node ); int maxLength = 10000; - outer: while ( ! next.isEmpty() ) + outer: + while ( !next.isEmpty() ) { - HashSet current = next; + Iterable current = next; next = new HashSet(); for ( IGridNode n : current ) @@ -133,15 +129,15 @@ public class ToolDebugCard extends AEBaseItem if ( center.getMachine() instanceof PartP2PTunnel ) { - this.outputMsg( player, "Freq: " + ((PartP2PTunnel) center.getMachine()).freq ); + this.outputMsg( player, "Freq: " + ( (PartP2PTunnel) center.getMachine() ).freq ); } TickManagerCache tmc = g.getCache( ITickManager.class ); - for (Class c : g.getMachineClasses()) + for ( Class c : g.getMachineClasses() ) { int o = 0; long nanos = 0; - for (IGridNode oj : g.getMachines( c )) + for ( IGridNode oj : g.getMachines( c ) ) { o++; nanos += tmc.getAvgNanoTime( oj ); @@ -165,13 +161,13 @@ public class ToolDebugCard extends AEBaseItem if ( te instanceof IPartHost ) { - IPart center = ((IPartHost) te).getPart( ForgeDirection.UNKNOWN ); - ((IPartHost) te).markForUpdate(); + IPart center = ( (IPartHost) te ).getPart( ForgeDirection.UNKNOWN ); + ( (IPartHost) te ).markForUpdate(); if ( center != null ) { GridNode n = (GridNode) center.getGridNode(); this.outputMsg( player, "Node Channels: " + n.usedChannels() ); - for (IGridConnection gc : n.getConnections()) + for ( IGridConnection gc : n.getConnections() ) { ForgeDirection fd = gc.getDirection( n ); if ( fd != ForgeDirection.UNKNOWN ) @@ -187,7 +183,7 @@ public class ToolDebugCard extends AEBaseItem if ( te instanceof IGridHost ) { - IGridNode node = ((IGridHost) te).getGridNode( ForgeDirection.getOrientation( side ) ); + IGridNode node = ( (IGridHost) te ).getGridNode( ForgeDirection.getOrientation( side ) ); if ( node != null && node.getGrid() != null ) { IEnergyGrid eg = node.getGrid().getCache( IEnergyGrid.class ); @@ -199,9 +195,16 @@ public class ToolDebugCard extends AEBaseItem return true; } - private void outputMsg(EntityPlayer player, String string) + private void outputMsg( ICommandSender player, String string ) { player.addChatMessage( new ChatComponentText( string ) ); } + public String timeMeasurement( long nanos ) + { + long ms = nanos / 100000; + if ( nanos <= 100000 ) + return nanos + "ns"; + return ( ms / 10.0f ) + "ms"; + } } diff --git a/src/main/java/appeng/debug/ToolEraser.java b/src/main/java/appeng/debug/ToolEraser.java index cfcda0456..c4d07caea 100644 --- a/src/main/java/appeng/debug/ToolEraser.java +++ b/src/main/java/appeng/debug/ToolEraser.java @@ -18,6 +18,8 @@ package appeng.debug; + +import java.util.Collection; import java.util.EnumSet; import java.util.LinkedList; import java.util.List; @@ -35,16 +37,25 @@ import appeng.core.features.AEFeature; import appeng.items.AEBaseItem; import appeng.util.Platform; + public class ToolEraser extends AEBaseItem { - public ToolEraser() { - super( ToolEraser.class ); + public static final int BLOCK_ERASE_LIMIT = 90000; + + public ToolEraser() + { this.setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) ); } @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + public void registerIcons( IIconRegister par1IconRegister ) + { + this.itemIcon = new MissingIcon( this ); + } + + @Override + public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ ) { if ( Platform.isClient() ) return false; @@ -56,13 +67,12 @@ public class ToolEraser extends AEBaseItem List next = new LinkedList(); next.add( new WorldCoord( x, y, z ) ); - while (blocks < 90000 && !next.isEmpty()) + while ( blocks < BLOCK_ERASE_LIMIT && !next.isEmpty() ) { - List c = next; next = new LinkedList(); - for (WorldCoord wc : c) + for ( WorldCoord wc : c ) { Block c_blk = world.getBlock( wc.x, wc.y, wc.z ); int c_meta = world.getBlockMetadata( wc.x, wc.y, wc.z ); @@ -72,15 +82,14 @@ public class ToolEraser extends AEBaseItem blocks++; world.setBlock( wc.x, wc.y, wc.z, Platform.AIR ); - this.check( world, wc.x + 1, wc.y, wc.z, next ); - this.check( world, wc.x - 1, wc.y, wc.z, next ); - this.check( world, wc.x, wc.y + 1, wc.z, next ); - this.check( world, wc.x, wc.y - 1, wc.z, next ); - this.check( world, wc.x, wc.y, wc.z + 1, next ); - this.check( world, wc.x, wc.y, wc.z - 1, next ); + this.wrappedAdd( world, wc.x + 1, wc.y, wc.z, next ); + this.wrappedAdd( world, wc.x - 1, wc.y, wc.z, next ); + this.wrappedAdd( world, wc.x, wc.y + 1, wc.z, next ); + this.wrappedAdd( world, wc.x, wc.y - 1, wc.z, next ); + this.wrappedAdd( world, wc.x, wc.y, wc.z + 1, next ); + this.wrappedAdd( world, wc.x, wc.y, wc.z - 1, next ); } } - } AELog.info( "Delete " + blocks + " blocks" ); @@ -88,15 +97,8 @@ public class ToolEraser extends AEBaseItem return true; } - private void check(World world, int i, int y, int z, List next) + private void wrappedAdd( World world, int i, int y, int z, Collection next ) { next.add( new WorldCoord( i, y, z ) ); } - - @Override - public void registerIcons(IIconRegister par1IconRegister) - { - this.itemIcon = new MissingIcon( this ); - } - } diff --git a/src/main/java/appeng/debug/ToolMeteoritePlacer.java b/src/main/java/appeng/debug/ToolMeteoritePlacer.java index ffc3ebeef..a60a45485 100644 --- a/src/main/java/appeng/debug/ToolMeteoritePlacer.java +++ b/src/main/java/appeng/debug/ToolMeteoritePlacer.java @@ -18,6 +18,7 @@ package appeng.debug; + import java.util.EnumSet; import net.minecraft.client.renderer.texture.IIconRegister; @@ -28,37 +29,37 @@ import net.minecraft.world.World; import appeng.client.texture.MissingIcon; import appeng.core.features.AEFeature; -import appeng.helpers.MeteoritePlacer; +import appeng.worldgen.MeteoritePlacer; +import appeng.worldgen.meteorite.StandardWorld; import appeng.items.AEBaseItem; import appeng.util.Platform; + public class ToolMeteoritePlacer extends AEBaseItem { - - public ToolMeteoritePlacer() { - super( ToolMeteoritePlacer.class ); + public ToolMeteoritePlacer() + { this.setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) ); } @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + public void registerIcons( IIconRegister par1IconRegister ) + { + this.itemIcon = new MissingIcon( this ); + } + + @Override + public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ ) { if ( Platform.isClient() ) return false; MeteoritePlacer mp = new MeteoritePlacer(); - boolean worked = mp.spawnMeteorite( new MeteoritePlacer.StandardWorld( world ), x, y, z ); + boolean worked = mp.spawnMeteorite( new StandardWorld( world ), x, y, z ); if ( !worked ) player.addChatMessage( new ChatComponentText( "Un-suitable Location." ) ); return true; } - - @Override - public void registerIcons(IIconRegister par1IconRegister) - { - this.itemIcon = new MissingIcon( this ); - } - } diff --git a/src/main/java/appeng/debug/ToolReplicatorCard.java b/src/main/java/appeng/debug/ToolReplicatorCard.java index 3516739ed..148dc7877 100644 --- a/src/main/java/appeng/debug/ToolReplicatorCard.java +++ b/src/main/java/appeng/debug/ToolReplicatorCard.java @@ -18,9 +18,11 @@ package appeng.debug; + import java.util.EnumSet; import net.minecraft.block.Block; +import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -39,16 +41,16 @@ import appeng.core.features.AEFeature; import appeng.items.AEBaseItem; import appeng.util.Platform; + public class ToolReplicatorCard extends AEBaseItem { - - public ToolReplicatorCard() { - super( ToolReplicatorCard.class ); + public ToolReplicatorCard() + { this.setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) ); } @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ ) { if ( Platform.isClient() ) return false; @@ -114,9 +116,9 @@ public class ToolReplicatorCard extends AEBaseItem int scale_y = max.y - min.y; int scale_z = max.z - min.z; - for (int i = 1; i < scale_x; i++) - for (int j = 1; j < scale_y; j++) - for (int k = 1; k < scale_z; k++) + for ( int i = 1; i < scale_x; i++ ) + for ( int j = 1; j < scale_y; j++ ) + for ( int k = 1; k < scale_z; k++ ) { Block blk = src_w.getBlock( min_x + i, min_y + j, min_z + k ); int meta = src_w.getBlockMetadata( min_x + i, min_y + j, min_z + k ); @@ -133,7 +135,6 @@ public class ToolReplicatorCard extends AEBaseItem } world.markBlockForUpdate( i + rel_x, j + rel_y, k + rel_z ); } - } else this.outputMsg( player, "requires valid spatial pylon setup." ); @@ -153,9 +154,8 @@ public class ToolReplicatorCard extends AEBaseItem return true; } - private void outputMsg(EntityPlayer player, String string) + private void outputMsg( ICommandSender player, String string ) { player.addChatMessage( new ChatComponentText( string ) ); } - } diff --git a/src/main/java/appeng/entity/EntityChargedQuartz.java b/src/main/java/appeng/entity/EntityChargedQuartz.java index 797226aa0..4a276bdf5 100644 --- a/src/main/java/appeng/entity/EntityChargedQuartz.java +++ b/src/main/java/appeng/entity/EntityChargedQuartz.java @@ -30,10 +30,12 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; import appeng.api.AEApi; +import appeng.api.definitions.IMaterials; import appeng.client.EffectType; import appeng.core.AEConfig; import appeng.core.CommonHelper; import appeng.core.features.AEFeature; +import appeng.helpers.Reflected; import appeng.util.Platform; final public class EntityChargedQuartz extends AEBaseEntityItem @@ -42,6 +44,7 @@ final public class EntityChargedQuartz extends AEBaseEntityItem int delay = 0; int transformTime = 0; + @Reflected public EntityChargedQuartz(World w) { super( w ); @@ -88,7 +91,9 @@ final public class EntityChargedQuartz extends AEBaseEntityItem public boolean transform() { ItemStack item = this.getEntityItem(); - if ( AEApi.instance().materials().materialCertusQuartzCrystalCharged.sameAsStack( item ) ) + final IMaterials materials = AEApi.instance().definitions().materials(); + + if ( materials.certusQuartzCrystalCharged().isSameAs( item ) ) { AxisAlignedBB region = AxisAlignedBB.getBoundingBox( this.posX - 1, this.posY - 1, this.posZ - 1, this.posX + 1, this.posY + 1, this.posZ + 1 ); List l = this.getCheckedEntitiesWithinAABBExcludingEntity( region ); @@ -127,12 +132,17 @@ final public class EntityChargedQuartz extends AEBaseEntityItem if ( netherQuartz.getEntityItem().stackSize <= 0 ) netherQuartz.setDead(); - ItemStack Output = AEApi.instance().materials().materialFluixCrystal.stack( 2 ); - this.worldObj.spawnEntityInWorld( new EntityItem( this.worldObj, this.posX, this.posY, this.posZ, Output ) ); + for ( ItemStack fluixCrystalStack : materials.fluixCrystal().maybeStack( 2 ).asSet() ) + { + final EntityItem entity = new EntityItem( this.worldObj, this.posX, this.posY, this.posZ, fluixCrystalStack ); + + this.worldObj.spawnEntityInWorld( entity ); + } return true; } } + return false; } } diff --git a/src/main/java/appeng/entity/EntitySingularity.java b/src/main/java/appeng/entity/EntitySingularity.java index e45893f98..78fb5b9ba 100644 --- a/src/main/java/appeng/entity/EntitySingularity.java +++ b/src/main/java/appeng/entity/EntitySingularity.java @@ -32,8 +32,10 @@ import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; import appeng.api.AEApi; +import appeng.api.definitions.IMaterials; import appeng.core.AEConfig; import appeng.core.features.AEFeature; +import appeng.helpers.Reflected; import appeng.util.Platform; @@ -42,6 +44,7 @@ final public class EntitySingularity extends AEBaseEntityItem static private int randTickSeed = 0; + @Reflected public EntitySingularity( World w ) { super( w ); @@ -73,7 +76,10 @@ final public class EntitySingularity extends AEBaseEntityItem return; ItemStack item = this.getEntityItem(); - if ( AEApi.instance().materials().materialSingularity.sameAsStack( item ) ) + + final IMaterials materials = AEApi.instance().definitions().materials(); + + if ( materials.singularity().isSameAs( item ) ) { AxisAlignedBB region = AxisAlignedBB.getBoundingBox( this.posX - 4, this.posY - 4, this.posZ - 4, this.posX + 4, this.posY + 4, this.posZ + 4 ); List l = this.getCheckedEntitiesWithinAABBExcludingEntity( region ); @@ -116,13 +122,16 @@ final public class EntitySingularity extends AEBaseEntityItem if ( other.stackSize == 0 ) e.setDead(); - ItemStack Output = AEApi.instance().materials().materialQESingularity.stack( 2 ); - NBTTagCompound cmp = Platform.openNbtData( Output ); - cmp.setLong( "freq", ( new Date() ).getTime() * 100 + ( randTickSeed ) % 100 ); - randTickSeed++; - item.stackSize--; + for ( ItemStack singularityStack : materials.qESingularity().maybeStack( 2 ).asSet() ) + { + NBTTagCompound cmp = Platform.openNbtData( singularityStack ); + cmp.setLong( "freq", ( new Date() ).getTime() * 100 + ( randTickSeed ) % 100 ); + randTickSeed++; + item.stackSize--; - this.worldObj.spawnEntityInWorld( new EntitySingularity( this.worldObj, this.posX, this.posY, this.posZ, Output ) ); + final EntitySingularity entity = new EntitySingularity( this.worldObj, this.posX, this.posY, this.posZ, singularityStack ); + this.worldObj.spawnEntityInWorld( entity ); + } } if ( item.stackSize <= 0 ) diff --git a/src/main/java/appeng/entity/EntityTinyTNTPrimed.java b/src/main/java/appeng/entity/EntityTinyTNTPrimed.java index b3818cbf4..9d22d4019 100644 --- a/src/main/java/appeng/entity/EntityTinyTNTPrimed.java +++ b/src/main/java/appeng/entity/EntityTinyTNTPrimed.java @@ -26,6 +26,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityTNTPrimed; +import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.world.Explosion; @@ -38,11 +39,12 @@ import appeng.core.AEConfig; import appeng.core.CommonHelper; import appeng.core.features.AEFeature; import appeng.core.sync.packets.PacketMockExplosion; +import appeng.helpers.Reflected; import appeng.util.Platform; final public class EntityTinyTNTPrimed extends EntityTNTPrimed implements IEntityAdditionalSpawnData { - + @Reflected public EntityTinyTNTPrimed(World w) { super( w ); this.setSize( 0.35F, 0.35F ); @@ -80,15 +82,20 @@ final public class EntityTinyTNTPrimed extends EntityTNTPrimed implements IEntit if ( this.isInWater() && Platform.isServer() ) // put out the fuse. { - EntityItem item = new EntityItem( this.worldObj, this.posX, this.posY, this.posZ, AEApi.instance().blocks().blockTinyTNT.stack( 1 ) ); - item.motionX = this.motionX; - item.motionY = this.motionY; - item.motionZ = this.motionZ; - item.prevPosX = this.prevPosX; - item.prevPosY = this.prevPosY; - item.prevPosZ = this.prevPosZ; - this.worldObj.spawnEntityInWorld( item ); - this.setDead(); + for ( ItemStack tntStack : AEApi.instance().definitions().blocks().tinyTNT().maybeStack( 1 ).asSet() ) + { + final EntityItem item = new EntityItem( this.worldObj, this.posX, this.posY, this.posZ, tntStack ); + + item.motionX = this.motionX; + item.motionY = this.motionY; + item.motionZ = this.motionZ; + item.prevPosX = this.prevPosX; + item.prevPosY = this.prevPosY; + item.prevPosZ = this.prevPosZ; + + this.worldObj.spawnEntityInWorld( item ); + this.setDead(); + } } if ( this.fuse <= 0 ) diff --git a/src/main/java/appeng/facade/FacadeContainer.java b/src/main/java/appeng/facade/FacadeContainer.java index 5209196b3..cb640b186 100644 --- a/src/main/java/appeng/facade/FacadeContainer.java +++ b/src/main/java/appeng/facade/FacadeContainer.java @@ -99,12 +99,15 @@ public class FacadeContainer implements IFacadeContainer } else if ( !isBC ) { - ItemFacade ifa = (ItemFacade) AEApi.instance().items().itemFacade.item(); - ItemStack facade = ifa.createFromIDs( ids ); - if ( facade != null ) + for ( Item facadeItem : AEApi.instance().definitions().items().facade().maybeItem().asSet() ) { - changed = changed || this.storage.getFacade( x ) == null; - this.storage.setFacade( x, ifa.createPartFromItemStack( facade, side ) ); + ItemFacade ifa = (ItemFacade) facadeItem; + ItemStack facade = ifa.createFromIDs( ids ); + if ( facade != null ) + { + changed = changed || this.storage.getFacade( x ) == null; + this.storage.setFacade( x, ifa.createPartFromItemStack( facade, side ) ); + } } } } diff --git a/src/main/java/appeng/fmp/PartRegistry.java b/src/main/java/appeng/fmp/PartRegistry.java index 4cde45b7c..c36a40866 100644 --- a/src/main/java/appeng/fmp/PartRegistry.java +++ b/src/main/java/appeng/fmp/PartRegistry.java @@ -51,7 +51,7 @@ public enum PartRegistry try { if ( this == CableBusPart ) - return (TMultiPart) Api.INSTANCE.partHelper.getCombinedInstance( this.part.getName() ).newInstance(); + return (TMultiPart) Api.INSTANCE.getPartHelper().getCombinedInstance( this.part.getName() ).newInstance(); else return this.part.getConstructor( int.class ).newInstance( meta ); } diff --git a/src/main/java/appeng/fmp/QuartzTorchPart.java b/src/main/java/appeng/fmp/QuartzTorchPart.java index 0a265e965..2a13a4546 100644 --- a/src/main/java/appeng/fmp/QuartzTorchPart.java +++ b/src/main/java/appeng/fmp/QuartzTorchPart.java @@ -31,6 +31,8 @@ import codechicken.multipart.minecraft.McBlockPart; import codechicken.multipart.minecraft.McSidedMetaPart; import appeng.api.AEApi; +import appeng.api.exceptions.MissingDefinition; + public class QuartzTorchPart extends McSidedMetaPart implements IRandomDisplayTick { @@ -52,7 +54,12 @@ public class QuartzTorchPart extends McSidedMetaPart implements IRandomDisplayTi @Override public Block getBlock() { - return AEApi.instance().blocks().blockQuartzTorch.block(); + for ( Block torchBlock : AEApi.instance().definitions().blocks().quartzTorch().maybeBlock().asSet() ) + { + return torchBlock; + } + + throw new MissingDefinition( "Tried to retrieve a quartz torch, even though it is disabled." ); } @Override diff --git a/src/main/java/appeng/helpers/DualityInterface.java b/src/main/java/appeng/helpers/DualityInterface.java index 370403434..094b3984b 100644 --- a/src/main/java/appeng/helpers/DualityInterface.java +++ b/src/main/java/appeng/helpers/DualityInterface.java @@ -18,6 +18,7 @@ package appeng.helpers; + import java.util.EnumSet; import java.util.HashSet; import java.util.Iterator; @@ -25,8 +26,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; -import com.google.common.collect.ImmutableSet; - import net.minecraft.block.Block; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; @@ -41,6 +40,8 @@ import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import com.google.common.collect.ImmutableSet; + import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.config.Settings; @@ -79,6 +80,7 @@ import appeng.me.helpers.AENetworkProxy; import appeng.me.storage.MEMonitorIInventory; import appeng.me.storage.MEMonitorPassThrough; import appeng.me.storage.NullInventory; +import appeng.parts.automation.StackUpgradeInventory; import appeng.parts.automation.UpgradeInventory; import appeng.tile.inventory.AppEngInternalAEInventory; import appeng.tile.inventory.AppEngInternalInventory; @@ -217,7 +219,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn this.gridProxy = networkProxy; this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL ); - this.upgrades = new UpgradeInventory( this.gridProxy.getMachineRepresentation(), this, 1 ); + this.upgrades = new StackUpgradeInventory( this.gridProxy.getMachineRepresentation(), this, 1 ); this.cm.registerSetting( Settings.BLOCK, YesNo.NO ); this.cm.registerSetting( Settings.INTERFACE_TERMINAL, YesNo.YES ); diff --git a/src/main/java/appeng/helpers/MeteoritePlacer.java b/src/main/java/appeng/helpers/MeteoritePlacer.java deleted file mode 100644 index bdb0d3ad8..000000000 --- a/src/main/java/appeng/helpers/MeteoritePlacer.java +++ /dev/null @@ -1,846 +0,0 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. - * - * Applied Energistics 2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Applied Energistics 2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Applied Energistics 2. If not, see . - */ - -package appeng.helpers; - -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.oredict.OreDictionary; - -import appeng.api.AEApi; -import appeng.core.AEConfig; -import appeng.core.WorldSettings; -import appeng.core.features.AEFeature; -import appeng.util.InventoryAdaptor; -import appeng.util.Platform; - -public class MeteoritePlacer -{ - - private class Fallout - { - - public int adjustCrater() - { - return 0; - } - - public void getRandomFall(IMeteoriteWorld w, int x, int y, int z) - { - double a = Math.random(); - if ( a > 0.9 ) - MeteoritePlacer.this.put( w, x, y, z, Blocks.stone ); - else if ( a > 0.8 ) - MeteoritePlacer.this.put( w, x, y, z, Blocks.cobblestone ); - else if ( a > 0.7 ) - MeteoritePlacer.this.put( w, x, y, z, Blocks.dirt ); - else if ( a > 0.7 ) - MeteoritePlacer.this.put( w, x, y, z, Blocks.gravel ); - } - - public void getRandomInset(IMeteoriteWorld w, int x, int y, int z) - { - double a = Math.random(); - if ( a > 0.9 ) - MeteoritePlacer.this.put( w, x, y, z, Blocks.cobblestone ); - else if ( a > 0.8 ) - MeteoritePlacer.this.put( w, x, y, z, Blocks.stone ); - else if ( a > 0.7 ) - MeteoritePlacer.this.put( w, x, y, z, Blocks.grass ); - else if ( a > 0.6 ) - MeteoritePlacer.this.put( w, x, y, z, MeteoritePlacer.this.skystone ); - else if ( a > 0.5 ) - MeteoritePlacer.this.put( w, x, y, z, Blocks.gravel ); - else if ( a > 0.5 ) - MeteoritePlacer.this.put( w, x, y, z, Platform.AIR ); - } - - } - - private class FalloutCopy extends Fallout - { - - final Block blk; - final int meta; - - public FalloutCopy(IMeteoriteWorld w, int x, int y, int z) { - this.blk = w.getBlock( x, y, z ); - this.meta = w.getBlockMetadata( x, y, z ); - } - - public void getOther(IMeteoriteWorld w, int x, int y, int z, double a) - { - - } - - @Override - public void getRandomFall(IMeteoriteWorld w, int x, int y, int z) - { - double a = Math.random(); - if ( a > 0.9 ) - MeteoritePlacer.this.put( w, x, y, z, this.blk, this.meta ); - else - this.getOther( w, x, y, z, a ); - } - - @Override - public void getRandomInset(IMeteoriteWorld w, int x, int y, int z) - { - double a = Math.random(); - if ( a > 0.9 ) - MeteoritePlacer.this.put( w, x, y, z, this.blk, this.meta ); - else if ( a > 0.8 ) - MeteoritePlacer.this.put( w, x, y, z, Platform.AIR ); - else - this.getOther( w, x, y, z, a - 0.1 ); - } - } - - private class FalloutSand extends FalloutCopy - { - - public FalloutSand(IMeteoriteWorld w, int x, int y, int z) { - super( w, x, y, z ); - } - - @Override - public int adjustCrater() - { - return 2; - } - - @Override - public void getOther(IMeteoriteWorld w, int x, int y, int z, double a) - { - if ( a > 0.66 ) - MeteoritePlacer.this.put( w, x, y, z, Blocks.glass ); - } - - } - - private class FalloutSnow extends FalloutCopy - { - - public FalloutSnow(IMeteoriteWorld w, int x, int y, int z) { - super( w, x, y, z ); - } - - @Override - public int adjustCrater() - { - return 2; - } - - @Override - public void getOther(IMeteoriteWorld w, int x, int y, int z, double a) - { - if ( a > 0.7 ) - MeteoritePlacer.this.put( w, x, y, z, Blocks.snow ); - else if ( a > 0.5 ) - MeteoritePlacer.this.put( w, x, y, z, Blocks.ice ); - } - - } - - public interface IMeteoriteWorld - { - - int minX(int in); - - int minZ(int in); - - int maxX(int in); - - int maxZ(int in); - - boolean hasNoSky(); - - int getBlockMetadata(int x, int y, int z); - - Block getBlock(int x, int y, int z); - - boolean canBlockSeeTheSky(int i, int j, int k); - - TileEntity getTileEntity(int x, int y, int z); - - World getWorld(); - - void setBlock(int i, int j, int k, Block blk); - - void setBlock(int i, int j, int k, Block blk_b, int meta_b, int l); - - void done(); - - } - - static public class StandardWorld implements IMeteoriteWorld - { - - protected final World w; - - public StandardWorld(World w) { - this.w = w; - } - - @Override - public boolean hasNoSky() - { - return !this.w.provider.hasNoSky; - } - - @Override - public int getBlockMetadata(int x, int y, int z) - { - if ( this.range( x, y, z ) ) - return this.w.getBlockMetadata( x, y, z ); - return 0; - } - - @Override - public Block getBlock(int x, int y, int z) - { - if ( this.range( x, y, z ) ) - return this.w.getBlock( x, y, z ); - return Platform.AIR; - } - - @Override - public boolean canBlockSeeTheSky(int x, int y, int z) - { - if ( this.range( x, y, z ) ) - return this.w.canBlockSeeTheSky( x, y, z ); - return false; - } - - @Override - public TileEntity getTileEntity(int x, int y, int z) - { - if ( this.range( x, y, z ) ) - return this.w.getTileEntity( x, y, z ); - return null; - } - - @Override - public World getWorld() - { - return this.w; - } - - @Override - public void setBlock(int x, int y, int z, Block blk) - { - if ( this.range( x, y, z ) ) - this.w.setBlock( x, y, z, blk ); - } - - @Override - public void setBlock(int x, int y, int z, Block blk, int metadata, int flags) - { - if ( this.range( x, y, z ) ) - this.w.setBlock( x, y, z, blk, metadata, flags ); - } - - public boolean range(int x, int y, int z) - { - return true; - } - - @Override - public int minX(int in) - { - return in; - } - - @Override - public int minZ(int in) - { - return in; - } - - @Override - public int maxX(int in) - { - return in; - } - - @Override - public int maxZ(int in) - { - return in; - } - - @Override - public void done() - { - - } - - } - - static public class ChunkOnly extends StandardWorld - { - - final Chunk target; - - int verticalBits = 0; - - final int cx; - final int cz; - - public ChunkOnly(World w, int cx, int cz) { - super( w ); - this.target = w.getChunkFromChunkCoords( cx, cz ); - this.cx = cx; - this.cz = cz; - } - - @Override - public void done() - { - if ( this.verticalBits != 0 ) - Platform.sendChunk( this.target, this.verticalBits ); - } - - @Override - public void setBlock(int x, int y, int z, Block blk) - { - if ( this.range( x, y, z ) ) - { - this.verticalBits |= 1 << (y >> 4); - this.w.setBlock( x, y, z, blk, 0, 1 ); - } - } - - @Override - public void setBlock(int x, int y, int z, Block blk, int metadata, int flags) - { - if ( this.range( x, y, z ) ) - { - this.verticalBits |= 1 << (y >> 4); - this.w.setBlock( x, y, z, blk, metadata, flags & (~2) ); - } - } - - @Override - public Block getBlock(int x, int y, int z) - { - if ( this.range( x, y, z ) ) - return this.target.getBlock( x & 0xF, y, z & 0xF ); - return Platform.AIR; - } - - @Override - public int getBlockMetadata(int x, int y, int z) - { - if ( this.range( x, y, z ) ) - return this.target.getBlockMetadata( x & 0xF, y, z & 0xF ); - return 0; - } - - @Override - public boolean range(int x, int y, int z) - { - return this.cx == (x >> 4) && this.cz == (z >> 4); - } - - @Override - public int minX(int in) - { - return Math.max( in, this.cx << 4 ); - } - - @Override - public int minZ(int in) - { - return Math.max( in, this.cz << 4 ); - } - - @Override - public int maxX(int in) - { - return Math.min( in, (this.cx + 1) << 4 ); - } - - @Override - public int maxZ(int in) - { - return Math.min( in, (this.cz + 1) << 4 ); - } - } - - final int minBLocks = 200; - final HashSet validSpawn = new HashSet(); - final HashSet invalidSpawn = new HashSet(); - - Fallout type = new Fallout(); - - final Block skystone = AEApi.instance().blocks().blockSkyStone.block(); - final Block skychest; - - double real_sizeOfMeteorite = (Math.random() * 6.0) + 2; - double realCrater = this.real_sizeOfMeteorite * 2 + 5; - - double sizeOfMeteorite = this.real_sizeOfMeteorite * this.real_sizeOfMeteorite; - double crater = this.realCrater * this.realCrater; - - public MeteoritePlacer() { - - if ( AEApi.instance().blocks().blockSkyChest.block() == null ) - this.skychest = Blocks.chest; - else - this.skychest = AEApi.instance().blocks().blockSkyChest.block(); - - this.validSpawn.add( Blocks.stone ); - this.validSpawn.add( Blocks.cobblestone ); - this.validSpawn.add( Blocks.grass ); - this.validSpawn.add( Blocks.sand ); - this.validSpawn.add( Blocks.dirt ); - this.validSpawn.add( Blocks.gravel ); - this.validSpawn.add( Blocks.netherrack ); - this.validSpawn.add( Blocks.iron_ore ); - this.validSpawn.add( Blocks.gold_ore ); - this.validSpawn.add( Blocks.diamond_ore ); - this.validSpawn.add( Blocks.redstone_ore ); - this.validSpawn.add( Blocks.hardened_clay ); - this.validSpawn.add( Blocks.ice ); - this.validSpawn.add( Blocks.snow ); - - this.invalidSpawn.add( this.skystone ); - this.invalidSpawn.add( Blocks.planks ); - this.invalidSpawn.add( Blocks.iron_door ); - this.invalidSpawn.add( Blocks.iron_bars ); - this.invalidSpawn.add( Blocks.wooden_door ); - this.invalidSpawn.add( Blocks.brick_block ); - this.invalidSpawn.add( Blocks.clay ); - this.invalidSpawn.add( Blocks.water ); - this.invalidSpawn.add( Blocks.log ); - this.invalidSpawn.add( Blocks.log2 ); - } - - NBTTagCompound settings; - - public boolean spawnMeteorite(IMeteoriteWorld w, NBTTagCompound meteoriteBlob) - { - this.settings = meteoriteBlob; - - int x = this.settings.getInteger( "x" ); - int y = this.settings.getInteger( "y" ); - int z = this.settings.getInteger( "z" ); - - this.real_sizeOfMeteorite = this.settings.getDouble( "real_sizeOfMeteorite" ); - this.realCrater = this.settings.getDouble( "realCrater" ); - this.sizeOfMeteorite = this.settings.getDouble( "sizeOfMeteorite" ); - this.crater = this.settings.getDouble( "crater" ); - - Block blk = Block.getBlockById( this.settings.getInteger( "blk" ) ); - - if ( blk == Blocks.sand ) - this.type = new FalloutSand( w, x, y, z ); - else if ( blk == Blocks.hardened_clay ) - this.type = new FalloutCopy( w, x, y, z ); - else if ( blk == Blocks.ice || blk == Blocks.snow ) - this.type = new FalloutSnow( w, x, y, z ); - - int skyMode = this.settings.getInteger( "skyMode" ); - - // creator - if ( skyMode > 10 ) - this.placeCrater( w, x, y, z ); - - this.placeMeteorite( w, x, y, z ); - - // collapse blocks... - if ( skyMode > 3 ) - this.Decay( w, x, y, z ); - - w.done(); - return true; - } - - public double getSqDistance(int x, int z) - { - int Cx = this.settings.getInteger( "x" ) - x; - int Cz = this.settings.getInteger( "z" ) - z; - - return Cx * Cx + Cz * Cz; - } - - public boolean spawnMeteorite(IMeteoriteWorld w, int x, int y, int z) - { - int validBlocks = 0; - - if ( !w.hasNoSky() ) - return false; - - Block blk = w.getBlock( x, y, z ); - if ( !this.validSpawn.contains( blk ) ) - return false; // must spawn on a valid block.. - - this.settings = new NBTTagCompound(); - this.settings.setInteger( "x", x ); - this.settings.setInteger( "y", y ); - this.settings.setInteger( "z", z ); - this.settings.setInteger( "blk", Block.getIdFromBlock( blk ) ); - - this.settings.setDouble( "real_sizeOfMeteorite", this.real_sizeOfMeteorite ); - this.settings.setDouble( "realCrater", this.realCrater ); - this.settings.setDouble( "sizeOfMeteorite", this.sizeOfMeteorite ); - this.settings.setDouble( "crater", this.crater ); - - this.settings.setBoolean( "lava", Math.random() > 0.9 ); - - if ( blk == Blocks.sand ) - this.type = new FalloutSand( w, x, y, z ); - else if ( blk == Blocks.hardened_clay ) - this.type = new FalloutCopy( w, x, y, z ); - else if ( blk == Blocks.ice || blk == Blocks.snow ) - this.type = new FalloutSnow( w, x, y, z ); - - int realValidBlocks = 0; - - for (int i = x - 6; i < x + 6; i++) - for (int j = y - 6; j < y + 6; j++) - for (int k = z - 6; k < z + 6; k++) - { - blk = w.getBlock( i, j, k ); - if ( this.validSpawn.contains( blk ) ) - realValidBlocks++; - } - - for (int i = x - 15; i < x + 15; i++) - for (int j = y - 15; j < y + 15; j++) - for (int k = z - 15; k < z + 15; k++) - { - blk = w.getBlock( i, j, k ); - if ( this.invalidSpawn.contains( blk ) ) - return false; - if ( this.validSpawn.contains( blk ) ) - validBlocks++; - } - - if ( validBlocks > this.minBLocks && realValidBlocks > 80 ) - { - // we can spawn here! - - int skyMode = 0; - - for (int i = x - 15; i < x + 15; i++) - for (int j = y - 15; j < y + 11; j++) - for (int k = z - 15; k < z + 15; k++) - { - if ( w.canBlockSeeTheSky( i, j, k ) ) - skyMode++; - } - - boolean solid = true; - for (int j = y - 15; j < y - 1; j++) - { - if ( w.getBlock( x, j, z ) == Platform.AIR ) - solid = false; - } - - if ( !solid ) - skyMode = 0; - - // creator - if ( skyMode > 10 ) - this.placeCrater( w, x, y, z ); - - this.placeMeteorite( w, x, y, z ); - - // collapse blocks... - if ( skyMode > 3 ) - this.Decay( w, x, y, z ); - - this.settings.setInteger( "skyMode", skyMode ); - w.done(); - - WorldSettings.getInstance().addNearByMeteorites( w.getWorld().provider.dimensionId, x >> 4, z >> 4, this.settings ); - return true; - } - return false; - } - - private void placeCrater(IMeteoriteWorld w, int x, int y, int z) - { - boolean lava = this.settings.getBoolean( "lava" ); - - int maxY = 255; - int minX = w.minX( x - 200 ); - int maxX = w.maxX( x + 200 ); - int minZ = w.minZ( z - 200 ); - int maxZ = w.maxZ( z + 200 ); - - for (int j = y - 5; j < maxY; j++) - { - boolean changed = false; - - for (int i = minX; i < maxX; i++) - for (int k = minZ; k < maxZ; k++) - { - double dx = i - x; - double dz = k - z; - double h = y - this.real_sizeOfMeteorite + 1 + this.type.adjustCrater(); - - double distanceFrom = dx * dx + dz * dz; - - if ( j > h + distanceFrom * 0.02 ) - { - if ( lava && j < y && w.getBlock( x, y - 1, z ).isBlockSolid( w.getWorld(), i, j, k, 0 ) ) - { - if ( j > h + distanceFrom * 0.02 ) - this.put( w, i, j, k, Blocks.lava ); - } - else - changed = this.put( w, i, j, k, Platform.AIR ) || changed; - } - } - } - - for (Object o : w.getWorld().getEntitiesWithinAABB( EntityItem.class, - AxisAlignedBB.getBoundingBox( w.minX( x - 30 ), y - 5, w.minZ( z - 30 ), w.maxX( x + 30 ), y + 30, w.maxZ( z + 30 ) ) )) - { - Entity e = (Entity) o; - e.setDead(); - } - } - - private void placeMeteorite(IMeteoriteWorld w, int x, int y, int z) - { - int meteorXLength = w.minX( x - 8 ); - int meteorXHeight = w.maxX( x + 8 ); - int meteorZLength = w.minZ( z - 8 ); - int meteorZHeight = w.maxZ( z + 8 ); - - // spawn meteor - for (int i = meteorXLength; i < meteorXHeight; i++) - for (int j = y - 8; j < y + 8; j++) - for (int k = meteorZLength; k < meteorZHeight; k++) - { - double dx = i - x; - double dy = j - y; - double dz = k - z; - - if ( dx * dx * 0.7 + dy * dy * (j > y ? 1.4 : 0.8) + dz * dz * 0.7 < this.sizeOfMeteorite ) - this.put( w, i, j, k, this.skystone ); - } - - if ( AEConfig.instance.isFeatureEnabled( AEFeature.SpawnPressesInMeteorites ) ) - { - this.put( w, x, y, z, this.skychest ); - TileEntity te = w.getTileEntity( x, y, z ); - if ( te instanceof IInventory ) - { - InventoryAdaptor ap = InventoryAdaptor.getAdaptor( te, ForgeDirection.UP ); - - int primary = Math.max( 1, (int) (Math.random() * 4) ); - - if ( primary > 3 ) // in case math breaks... - primary = 3; - - for (int zz = 0; zz < primary; zz++) - { - int r = 0; - boolean duplicate = false; - - do - { - duplicate = false; - - if ( Math.random() > 0.7 ) - r = WorldSettings.getInstance().getNextOrderedValue( "presses" ); - else - r = (int) (Math.random() * 1000); - - ItemStack toAdd = null; - - switch (r % 4) - { - case 0: - toAdd = AEApi.instance().materials().materialCalcProcessorPress.stack( 1 ); - break; - case 1: - toAdd = AEApi.instance().materials().materialEngProcessorPress.stack( 1 ); - break; - case 2: - toAdd = AEApi.instance().materials().materialLogicProcessorPress.stack( 1 ); - break; - case 3: - toAdd = AEApi.instance().materials().materialSiliconPress.stack( 1 ); - break; - default: - } - - if ( toAdd != null ) - { - if ( ap.simulateRemove( 1, toAdd, null ) == null ) - ap.addItems( toAdd ); - else - duplicate = true; - } - } - while (duplicate); - } - - int secondary = Math.max( 1, (int) (Math.random() * 3) ); - for (int zz = 0; zz < secondary; zz++) - { - switch ((int) (Math.random() * 1000) % 3) - { - case 0: - ap.addItems( AEApi.instance().blocks().blockSkyStone.stack( (int) (Math.random() * 12) + 1 ) ); - break; - case 1: - List possibles = new LinkedList(); - possibles.addAll( OreDictionary.getOres( "nuggetIron" ) ); - possibles.addAll( OreDictionary.getOres( "nuggetCopper" ) ); - possibles.addAll( OreDictionary.getOres( "nuggetTin" ) ); - possibles.addAll( OreDictionary.getOres( "nuggetSilver" ) ); - possibles.addAll( OreDictionary.getOres( "nuggetLead" ) ); - possibles.addAll( OreDictionary.getOres( "nuggetPlatinum" ) ); - possibles.addAll( OreDictionary.getOres( "nuggetNickel" ) ); - possibles.addAll( OreDictionary.getOres( "nuggetAluminium" ) ); - possibles.addAll( OreDictionary.getOres( "nuggetElectrum" ) ); - possibles.add( new ItemStack( net.minecraft.init.Items.gold_nugget ) ); - - ItemStack nugget = Platform.pickRandom( possibles ); - if ( nugget != null ) - { - nugget = nugget.copy(); - nugget.stackSize = (int) (Math.random() * 12) + 1; - ap.addItems( nugget ); - } - break; - } - } - } - } - } - - private void Decay(IMeteoriteWorld w, int x, int y, int z) - { - double randomShit = 0; - - int meteorXLength = w.minX( x - 30 ); - int meteorXHeight = w.maxX( x + 30 ); - int meteorZLength = w.minZ( z - 30 ); - int meteorZHeight = w.maxZ( z + 30 ); - - for (int i = meteorXLength; i < meteorXHeight; i++) - for (int k = meteorZLength; k < meteorZHeight; k++) - for (int j = y - 9; j < y + 30; j++) - { - Block blk = w.getBlock( i, j, k ); - if ( blk == Blocks.lava ) - continue; - - if ( blk.isReplaceable( w.getWorld(), i, j, k ) ) - { - blk = Platform.AIR; - Block blk_b = w.getBlock( i, j + 1, k ); - - if ( blk_b != blk ) - { - int meta_b = w.getBlockMetadata( i, j + 1, k ); - - w.setBlock( i, j, k, blk_b, meta_b, 3 ); - w.setBlock( i, j + 1, k, blk ); - } - else if ( randomShit < 100 * this.crater ) - { - double dx = i - x; - double dy = j - y; - double dz = k - z; - double dist = dx * dx + dy * dy + dz * dz; - - Block xf = w.getBlock( i, j - 1, k ); - if ( !xf.isReplaceable( w.getWorld(), i, j - 1, k ) ) - { - double extraRange = Math.random() * 0.6; - double height = this.crater * (extraRange + 0.2) - Math.abs( dist - this.crater * 1.7 ); - - if ( xf != blk && height > 0 && Math.random() > 0.6 ) - { - randomShit++; - this.type.getRandomFall( w, i, j, k ); - } - } - } - } - else - { - // decay. - Block blk_b = w.getBlock( i, j + 1, k ); - if ( blk_b == Platform.AIR ) - { - if ( Math.random() > 0.4 ) - { - double dx = i - x; - double dy = j - y; - double dz = k - z; - - if ( dx * dx + dy * dy + dz * dz < this.crater * 1.6 ) - { - this.type.getRandomInset( w, i, j, k ); - } - - } - } - } - - } - } - - private boolean put(IMeteoriteWorld w, int i, int j, int k, Block blk) - { - Block original = w.getBlock( i, j, k ); - - if ( original == Blocks.bedrock || original == blk ) - return false; - - w.setBlock( i, j, k, blk ); - return true; - } - - private void put(IMeteoriteWorld w, int i, int j, int k, Block blk, int meta) - { - if ( w.getBlock( i, j, k ) == Blocks.bedrock ) - return; - - w.setBlock( i, j, k, blk, meta, 3 ); - } - - public NBTTagCompound getSettings() - { - return this.settings; - } -} diff --git a/src/main/java/appeng/helpers/Reflected.java b/src/main/java/appeng/helpers/Reflected.java new file mode 100644 index 000000000..411dd9c03 --- /dev/null +++ b/src/main/java/appeng/helpers/Reflected.java @@ -0,0 +1,18 @@ +package appeng.helpers; + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * Marker interface to help identify invocation of reflection + */ +@Retention( RetentionPolicy.SOURCE ) +@Target( { ElementType.CONSTRUCTOR, ElementType.FIELD } ) +public @interface Reflected +{ + +} diff --git a/src/main/java/appeng/hooks/AETrading.java b/src/main/java/appeng/hooks/AETrading.java index 4974a86cc..f6c26b0fd 100644 --- a/src/main/java/appeng/hooks/AETrading.java +++ b/src/main/java/appeng/hooks/AETrading.java @@ -28,7 +28,12 @@ import net.minecraft.village.MerchantRecipeList; import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; +import com.google.common.base.Optional; + import appeng.api.AEApi; +import appeng.api.definitions.IItemDefinition; +import appeng.api.definitions.IMaterials; + public class AETrading implements IVillageTradeHandler { @@ -48,60 +53,67 @@ public class AETrading implements IVillageTradeHandler l.add( new MerchantRecipe( a, b ) ); } - private void addTrade(MerchantRecipeList list, ItemStack a, ItemStack b, Random rand, int conversion_Variance) + private void addTrade(MerchantRecipeList list, IItemDefinition inputDefinition, IItemDefinition outputDefinition, Random rand, int conversionVariance) { - // Sell - ItemStack From = a.copy(); - ItemStack To = b.copy(); + final Optional maybeInputStack = inputDefinition.maybeStack( 1 ); + final Optional maybeOutputStack = outputDefinition.maybeStack( 1 ); - From.stackSize = 1 + (Math.abs( rand.nextInt() ) % (1 + conversion_Variance)); - To.stackSize = 1; + if ( maybeInputStack.isPresent() && maybeOutputStack.isPresent() ) + { + // Sell + ItemStack inputStack = maybeInputStack.get().copy(); + ItemStack outputStack = maybeOutputStack.get().copy(); - this.addToList( list, From, To ); + inputStack.stackSize = 1 + (Math.abs( rand.nextInt() ) % (1 + conversionVariance)); + outputStack.stackSize = 1; + + this.addToList( list, inputStack, outputStack ); + } } - private void addMerchant(MerchantRecipeList list, ItemStack item, int emera, Random rand, int greed) + private void addMerchant(MerchantRecipeList list, IItemDefinition item, int emera, Random rand, int greed) { - if ( item == null ) - return; - - // Sell - ItemStack From = item.copy(); - ItemStack To = new ItemStack( Items.emerald ); - - int multiplier = (Math.abs( rand.nextInt() ) % 6); - emera += (Math.abs( rand.nextInt() ) % greed) - multiplier; - int mood = rand.nextInt() % 2; - - From.stackSize = multiplier + mood; - To.stackSize = multiplier * emera - mood; - - if ( To.stackSize < 0 ) + for ( ItemStack itemStack : item.maybeStack( 1 ).asSet() ) { - From.stackSize -= To.stackSize; - To.stackSize -= To.stackSize; + // Sell + ItemStack from = itemStack.copy(); + ItemStack to = new ItemStack( Items.emerald ); + + int multiplier = (Math.abs( rand.nextInt() ) % 6); + final int emeraldCost = emera + (Math.abs( rand.nextInt() ) % greed) - multiplier; + int mood = rand.nextInt() % 2; + + from.stackSize = multiplier + mood; + to.stackSize = multiplier * emeraldCost - mood; + + if ( to.stackSize < 0 ) + { + from.stackSize -= to.stackSize; + to.stackSize -= to.stackSize; + } + + this.addToList( list, from, to ); + + // Buy + ItemStack reverseTo = from.copy(); + ItemStack reverseFrom = to.copy(); + + reverseFrom.stackSize *= rand.nextFloat() * 3.0f + 1.0f; + + this.addToList( list, reverseFrom, reverseTo ); } - - this.addToList( list, From, To ); - - // Buy - ItemStack reverseTo = From.copy(); - ItemStack reverseFrom = To.copy(); - - reverseFrom.stackSize *= rand.nextFloat() * 3.0f + 1.0f; - - this.addToList( list, reverseFrom, reverseTo ); } @Override public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) { - this.addMerchant( recipeList, AEApi.instance().materials().materialSilicon.stack( 1 ), 1, random, 2 ); - this.addMerchant( recipeList, AEApi.instance().materials().materialCertusQuartzCrystal.stack( 1 ), 2, random, 4 ); - this.addMerchant( recipeList, AEApi.instance().materials().materialCertusQuartzDust.stack( 1 ), 1, random, 3 ); + final IMaterials materials = AEApi.instance().definitions().materials(); - this.addTrade( recipeList, AEApi.instance().materials().materialCertusQuartzDust.stack( 1 ), - AEApi.instance().materials().materialCertusQuartzCrystal.stack( 1 ), random, 2 ); + this.addMerchant( recipeList, materials.silicon(), 1, random, 2 ); + this.addMerchant( recipeList, materials.certusQuartzCrystal(), 2, random, 4 ); + this.addMerchant( recipeList, materials.certusQuartzDust(), 1, random, 3 ); + + this.addTrade( recipeList, materials.certusQuartzDust(), materials.certusQuartzCrystal(), random, 2 ); } } diff --git a/src/main/java/appeng/integration/modules/BC.java b/src/main/java/appeng/integration/modules/BC.java index 6041f2040..5606016e2 100644 --- a/src/main/java/appeng/integration/modules/BC.java +++ b/src/main/java/appeng/integration/modules/BC.java @@ -19,7 +19,7 @@ package appeng.integration.modules; -import java.lang.reflect.Field; +import java.lang.reflect.Method; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; @@ -44,8 +44,10 @@ import buildcraft.transport.ItemFacade; import buildcraft.transport.PipeIconProvider; import appeng.api.AEApi; +import appeng.api.IAppEngApi; import appeng.api.config.TunnelType; -import appeng.api.definitions.Blocks; +import appeng.api.definitions.IBlockDefinition; +import appeng.api.definitions.IBlocks; import appeng.api.features.IP2PTunnelRegistry; import appeng.api.parts.IFacadePart; import appeng.api.util.AEItemDefinition; @@ -58,56 +60,58 @@ import appeng.integration.modules.BCHelpers.AEGenericSchematicTile; import appeng.integration.modules.BCHelpers.AERotatableBlockSchematic; import appeng.integration.modules.BCHelpers.BCPipeHandler; + public final class BC extends BaseModule implements IBC { public static BC instance; - public BC() { + public BC() + { this.testClassExistence( IPipeConnection.class ); this.testClassExistence( ItemFacade.class ); this.testClassExistence( IToolWrench.class ); } @Override - public void addFacade(ItemStack item) - { - if ( item != null ) - FMLInterModComms.sendMessage( "BuildCraft|Transport", "add-facade", item ); - } - - @Override - public boolean isWrench(Item eq) + public boolean isWrench( Item eq ) { return eq instanceof IToolWrench; } @Override - public boolean isPipe(TileEntity te, ForgeDirection dir) + public boolean canWrench( Item i, EntityPlayer p, int x, int y, int z ) { - if ( te instanceof IPipeTile ) + return ( (IToolWrench) i ).canWrench( p, x, y, z ); + } + + @Override + public void wrenchUsed( Item i, EntityPlayer p, int x, int y, int z ) + { + ( (IToolWrench) i ).wrenchUsed( p, x, y, z ); + } + + @Override + public boolean canAddItemsToPipe( TileEntity te, ItemStack is, ForgeDirection dir ) + { + if ( is != null && te != null && te instanceof IInjectable ) { - final IPipeTile pipeTile = (IPipeTile) te; - return !pipeTile.hasPipePluggable( dir.getOpposite() ); + IInjectable pt = (IInjectable) te; + if ( pt.canInjectItems( dir ) ) + { + int amt = pt.injectItem( is, false, dir, null ); + if ( amt == is.stackSize ) + { + return true; + } + } } return false; } @Override - public boolean canWrench(Item i, EntityPlayer p, int x, int y, int z) - { - return ((IToolWrench) i).canWrench( p, x, y, z ); - } - - @Override - public void wrenchUsed(Item i, EntityPlayer p, int x, int y, int z) - { - ((IToolWrench) i).wrenchUsed( p, x, y, z ); - } - - @Override - public boolean addItemsToPipe(TileEntity te, ItemStack is, ForgeDirection dir) + public boolean addItemsToPipe( TileEntity te, ItemStack is, ForgeDirection dir ) { if ( is != null && te != null && te instanceof IInjectable ) { @@ -127,7 +131,7 @@ public final class BC extends BaseModule implements IBC } @Override - public boolean isFacade(ItemStack is) + public boolean isFacade( ItemStack is ) { if ( is == null ) return false; @@ -136,24 +140,24 @@ public final class BC extends BaseModule implements IBC } @Override - public boolean canAddItemsToPipe(TileEntity te, ItemStack is, ForgeDirection dir) + public boolean isPipe( TileEntity te, ForgeDirection dir ) { - if ( is != null && te != null && te instanceof IInjectable ) + if ( te instanceof IPipeTile ) { - IInjectable pt = (IInjectable) te; - if ( pt.canInjectItems( dir ) ) - { - int amt = pt.injectItem( is, false, dir, null ); - if ( amt == is.stackSize ) - { - return true; - } - } + final IPipeTile pipeTile = (IPipeTile) te; + return !pipeTile.hasPipePluggable( dir.getOpposite() ); } return false; } + @Override + public void addFacade( ItemStack item ) + { + if ( item != null ) + FMLInterModComms.sendMessage( "BuildCraft|Transport", "add-facade", item ); + } + @Override public void registerPowerP2P() { @@ -201,82 +205,7 @@ public final class BC extends BaseModule implements IBC } @Override - public void init() - { - AEApi.instance().partHelper().registerNewLayer( "appeng.parts.layers.LayerIPipeConnection", "buildcraft.api.transport.IPipeConnection" ); - AEApi.instance().registries().externalStorage().addExternalStorageInterface( new BCPipeHandler() ); - - Blocks b = AEApi.instance().blocks(); - this.addFacade( b.blockFluix.stack( 1 ) ); - this.addFacade( b.blockQuartz.stack( 1 ) ); - this.addFacade( b.blockQuartzChiseled.stack( 1 ) ); - this.addFacade( b.blockQuartzPillar.stack( 1 ) ); - - try - { - this.initBuilderSupport(); - } - catch (Throwable builderSupport) - { - // not supported? - } - - Block skyStone = b.blockSkyStone.block(); - if ( skyStone != null ) - { - this.addFacade( new ItemStack( skyStone, 1, 0 ) ); - this.addFacade( new ItemStack( skyStone, 1, 1 ) ); - this.addFacade( new ItemStack( skyStone, 1, 2 ) ); - this.addFacade( new ItemStack( skyStone, 1, 3 ) ); - } - } - - private void initBuilderSupport() - { - final ISchematicRegistry schematicRegistry = BuilderAPI.schematicRegistry; - - Blocks blocks = AEApi.instance().blocks(); - Block cable = blocks.blockMultiPart.block(); - for (Field f : blocks.getClass().getFields()) - { - AEItemDefinition def; - try - { - def = (AEItemDefinition) f.get( blocks ); - if ( def != null ) - { - Block myBlock = def.block(); - if ( myBlock instanceof IOrientableBlock && ((IOrientableBlock) myBlock).usesMetadata() && def.entity() == null ) - { - schematicRegistry.registerSchematicBlock( myBlock, AERotatableBlockSchematic.class ); - } - else if ( myBlock == cable ) - { - schematicRegistry.registerSchematicBlock( myBlock, AECableSchematicTile.class ); - } - else if ( def.entity() != null ) - { - schematicRegistry.registerSchematicBlock( myBlock, AEGenericSchematicTile.class ); - } - } - } - catch (Throwable t) - { - // :P - } - } - } - - @Override - public void postInit() - { - this.registerPowerP2P(); - this.registerItemP2P(); - this.registerLiquidsP2P(); - } - - @Override - public IFacadePart createFacadePart(Block blk, int meta, ForgeDirection side) + public IFacadePart createFacadePart( Block blk, int meta, ForgeDirection side ) { try { @@ -285,7 +214,7 @@ public final class BC extends BaseModule implements IBC return new FacadePart( facade, side ); } - catch (Throwable ignored) + catch ( Throwable ignored ) { } @@ -294,17 +223,17 @@ public final class BC extends BaseModule implements IBC } @Override - public IFacadePart createFacadePart(ItemStack fs, ForgeDirection side) + public IFacadePart createFacadePart( ItemStack fs, ForgeDirection side ) { return new FacadePart( fs, side ); } @Override - public ItemStack getTextureForFacade(ItemStack facade) + public ItemStack getTextureForFacade( ItemStack facade ) { final Item maybeFacadeItem = facade.getItem(); - if ( maybeFacadeItem instanceof buildcraft.api.facades.IFacadeItem) + if ( maybeFacadeItem instanceof buildcraft.api.facades.IFacadeItem ) { final buildcraft.api.facades.IFacadeItem facadeItem = (buildcraft.api.facades.IFacadeItem) maybeFacadeItem; @@ -327,11 +256,99 @@ public final class BC extends BaseModule implements IBC { return BuildCraftTransport.instance.pipeIconProvider.getIcon( PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal() ); // Structure } - catch (Throwable ignored) + catch ( Throwable ignored ) { } return null; // Pipe } + private void addFacadeStack( IBlockDefinition definition ) + { + for ( ItemStack facadeStack : definition.maybeStack( 1 ).asSet() ) + { + this.addFacade( facadeStack ); + } + } + + @Override + public void init() + { + final IAppEngApi api = AEApi.instance(); + + api.partHelper().registerNewLayer( "appeng.parts.layers.LayerIPipeConnection", "buildcraft.api.transport.IPipeConnection" ); + api.registries().externalStorage().addExternalStorageInterface( new BCPipeHandler() ); + + final IBlocks blocks = api.definitions().blocks(); + + this.addFacadeStack( blocks.fluix() ); + this.addFacadeStack( blocks.quartz() ); + this.addFacadeStack( blocks.quartzChiseled() ); + this.addFacadeStack( blocks.quartzPillar() ); + + try + { + this.initBuilderSupport(); + } + catch ( Throwable builderSupport ) + { + // not supported? + } + + for ( Block skyStoneBlock : blocks.skyStone().maybeBlock().asSet() ) + { + this.addFacade( new ItemStack( skyStoneBlock, 1, 0 ) ); + this.addFacade( new ItemStack( skyStoneBlock, 1, 1 ) ); + this.addFacade( new ItemStack( skyStoneBlock, 1, 2 ) ); + this.addFacade( new ItemStack( skyStoneBlock, 1, 3 ) ); + } + } + + private void initBuilderSupport() + { + final ISchematicRegistry schematicRegistry = BuilderAPI.schematicRegistry; + + final IBlocks blocks = AEApi.instance().definitions().blocks(); + final IBlockDefinition maybeMultiPart = blocks.multiPart(); + + for ( Method blockDefinition : blocks.getClass().getMethods() ) + { + AEItemDefinition def; + try + { + def = (AEItemDefinition) blockDefinition.invoke( blocks ); + + Block myBlock = def.block(); + if ( myBlock instanceof IOrientableBlock && ( (IOrientableBlock) myBlock ).usesMetadata() && def.entity() == null ) + { + schematicRegistry.registerSchematicBlock( myBlock, AERotatableBlockSchematic.class ); + } + else if ( maybeMultiPart.isSameAs( new ItemStack( myBlock ) ) ) + { + schematicRegistry.registerSchematicBlock( myBlock, AECableSchematicTile.class ); + } + else if ( def.entity() != null ) + { + schematicRegistry.registerSchematicBlock( myBlock, AEGenericSchematicTile.class ); + } + } + catch ( Throwable t ) + { + // :P + } + } + } + + @Override + public void postInit() + { + this.registerPowerP2P(); + this.registerItemP2P(); + this.registerLiquidsP2P(); + } + + private void registerOrientableBlocks() + { + + } } diff --git a/src/main/java/appeng/integration/modules/FMP.java b/src/main/java/appeng/integration/modules/FMP.java index 7bf34babe..5fa9b1571 100644 --- a/src/main/java/appeng/integration/modules/FMP.java +++ b/src/main/java/appeng/integration/modules/FMP.java @@ -18,7 +18,8 @@ package appeng.integration.modules; -import java.util.Arrays; +import java.util.Collection; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayerMP; @@ -36,9 +37,11 @@ import codechicken.multipart.MultiPartRegistry.IPartFactory; import codechicken.multipart.MultipartGenerator; import codechicken.multipart.TMultiPart; import codechicken.multipart.TileMultipart; +import com.google.common.collect.Lists; import appeng.api.AEApi; -import appeng.api.definitions.Blocks; +import appeng.api.definitions.IBlockDefinition; +import appeng.api.definitions.IBlocks; import appeng.api.parts.IPartHost; import appeng.core.AELog; import appeng.fmp.CableBusPart; @@ -86,13 +89,15 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF @Override public void init() throws Throwable { - this.createAndRegister( AEApi.instance().blocks().blockQuartz.block(), 0 ); - this.createAndRegister( AEApi.instance().blocks().blockQuartzPillar.block(), 0 ); - this.createAndRegister( AEApi.instance().blocks().blockQuartzChiseled.block(), 0 ); - this.createAndRegister( AEApi.instance().blocks().blockSkyStone.block(), 0 ); - this.createAndRegister( AEApi.instance().blocks().blockSkyStone.block(), 1 ); - this.createAndRegister( AEApi.instance().blocks().blockSkyStone.block(), 2 ); - this.createAndRegister( AEApi.instance().blocks().blockSkyStone.block(), 3 ); + final IBlocks blocks = AEApi.instance().definitions().blocks(); + + this.createAndRegister( blocks.quartz(), 0 ); + this.createAndRegister( blocks.quartzPillar(), 0 ); + this.createAndRegister( blocks.quartzChiseled(), 0 ); + this.createAndRegister( blocks.skyStone(), 0 ); + this.createAndRegister( blocks.skyStone(), 1 ); + this.createAndRegister( blocks.skyStone(), 2 ); + this.createAndRegister( blocks.skyStone(), 3 ); PartRegistry[] reg = PartRegistry.values(); @@ -106,10 +111,12 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF MultipartGenerator.registerPassThroughInterface( "appeng.helpers.AEMultiTile" ); } - private void createAndRegister(Block block, int i) + private void createAndRegister(IBlockDefinition definition, int i) { - if ( block != null ) + for ( Block block : definition.maybeBlock().asSet() ) + { BlockMicroMaterial.createAndRegister( block, i ); + } } @Override @@ -186,8 +193,20 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF @Override public Iterable blockTypes() { - Blocks def = AEApi.instance().blocks(); - return Arrays.asList( def.blockMultiPart.block(), def.blockQuartzTorch.block() ); + final IBlocks blocks = AEApi.instance().definitions().blocks(); + final List blockTypes = Lists.newArrayListWithCapacity( 2 ); + + this.addBlockTypes( blockTypes, blocks.multiPart() ); + this.addBlockTypes( blockTypes, blocks.quartzTorch() ); + + return blockTypes; } + private void addBlockTypes( Collection blockTypes, IBlockDefinition definition ) + { + for ( Block block : definition.maybeBlock().asSet() ) + { + blockTypes.add( block ); + } + } } diff --git a/src/main/java/appeng/integration/modules/ImmibisMicroblocks.java b/src/main/java/appeng/integration/modules/ImmibisMicroblocks.java index 70425fca3..67ce8bb1e 100644 --- a/src/main/java/appeng/integration/modules/ImmibisMicroblocks.java +++ b/src/main/java/appeng/integration/modules/ImmibisMicroblocks.java @@ -27,21 +27,24 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import com.google.common.base.Optional; import mods.immibis.core.api.multipart.ICoverSystem; import mods.immibis.core.api.multipart.IMultipartTile; import mods.immibis.core.api.multipart.IPartContainer; import appeng.api.AEApi; +import appeng.api.definitions.IBlockDefinition; import appeng.api.parts.IPartHost; import appeng.api.parts.IPartItem; import appeng.core.AELog; +import appeng.helpers.Reflected; import appeng.integration.BaseModule; import appeng.integration.abstraction.IImmibisMicroblocks; public class ImmibisMicroblocks extends BaseModule implements IImmibisMicroblocks { - + @Reflected public static ImmibisMicroblocks INSTANCE; private boolean canConvertTiles = false; @@ -102,19 +105,28 @@ public class ImmibisMicroblocks extends BaseModule implements IImmibisMicroblock if ( te instanceof IMultipartTile && this.canConvertTiles && isPartItem ) { - final Block blk = AEApi.instance().blocks().blockMultiPart.block(); - final ItemStack what = AEApi.instance().blocks().blockMultiPart.stack( 1 ); + final IBlockDefinition multiPart = AEApi.instance().definitions().blocks().multiPart(); + final Optional maybeMultiPartBlock = multiPart.maybeBlock(); + final Optional maybeMultiPartStack = multiPart.maybeStack( 1 ); - try + final boolean multiPartPresent = maybeMultiPartBlock.isPresent() && maybeMultiPartStack.isPresent(); + + if ( multiPartPresent ) { - // ItemStack.class, EntityPlayer.class, World.class, - // int.class, int.class, int.class, int.class, Block.class, int.class ); - this.mergeIntoMicroblockContainer.invoke( null, what, player, w, x, y, z, side, blk, 0 ); - } - catch ( Throwable e ) - { - this.canConvertTiles = false; - return null; + final Block multiPartBlock = maybeMultiPartBlock.get(); + final ItemStack multiPartStack = maybeMultiPartStack.get(); + + try + { + // ItemStack.class, EntityPlayer.class, World.class, + // int.class, int.class, int.class, int.class, Block.class, int.class ); + this.mergeIntoMicroblockContainer.invoke( null, multiPartStack, player, w, x, y, z, side, multiPartBlock, 0 ); + } + catch ( Throwable e ) + { + this.canConvertTiles = false; + return null; + } } } diff --git a/src/main/java/appeng/integration/modules/NEIHelpers/NEIFacadeRecipeHandler.java b/src/main/java/appeng/integration/modules/NEIHelpers/NEIFacadeRecipeHandler.java index 7f18d07ba..c55386a67 100644 --- a/src/main/java/appeng/integration/modules/NEIHelpers/NEIFacadeRecipeHandler.java +++ b/src/main/java/appeng/integration/modules/NEIHelpers/NEIFacadeRecipeHandler.java @@ -18,7 +18,8 @@ package appeng.integration.modules.NEIHelpers; -import java.awt.Rectangle; + +import java.awt.*; import java.util.ArrayList; import java.util.List; @@ -36,14 +37,25 @@ import codechicken.nei.recipe.RecipeInfo; import codechicken.nei.recipe.TemplateRecipeHandler; import appeng.api.AEApi; +import appeng.api.definitions.IDefinitions; +import appeng.api.definitions.IItemDefinition; import appeng.core.localization.GuiText; +import appeng.facade.IFacadeItem; import appeng.items.parts.ItemFacade; + public class NEIFacadeRecipeHandler extends TemplateRecipeHandler { + final ItemFacade facade; + final IItemDefinition anchorDefinition; - final ItemFacade ifa = (ItemFacade) AEApi.instance().items().itemFacade.item(); - final ItemStack cable_anchor = AEApi.instance().parts().partCableAnchor.stack( 1 ); + public NEIFacadeRecipeHandler() + { + final IDefinitions definitions = AEApi.instance().definitions(); + + this.facade = (ItemFacade) definitions.items().facade(); + this.anchorDefinition = definitions.parts().cableAnchor(); + } @Override public void loadTransferRects() @@ -52,29 +64,19 @@ public class NEIFacadeRecipeHandler extends TemplateRecipeHandler } @Override - public Class getGuiClass() + public void loadCraftingRecipes( String outputId, Object... results ) { - return GuiCrafting.class; - } - - @Override - public String getRecipeName() - { - return GuiText.FacadeCrafting.getLocal(); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if ( (outputId.equals( "crafting" )) && (this.getClass() == NEIFacadeRecipeHandler.class) ) + if ( ( outputId.equals( "crafting" ) ) && ( this.getClass() == NEIFacadeRecipeHandler.class ) ) { - ItemFacade ifa = (ItemFacade) AEApi.instance().items().itemFacade.item(); - List facades = ifa.getFacades(); - for (ItemStack is : facades) + final List facades = this.facade.getFacades(); + for ( ItemStack anchorStack : this.anchorDefinition.maybeStack( 1 ).asSet() ) { - CachedShapedRecipe recipe = new CachedShapedRecipe( is ); - recipe.computeVisuals(); - this.arecipes.add( recipe ); + for ( ItemStack is : facades ) + { + CachedShapedRecipe recipe = new CachedShapedRecipe( this.facade, anchorStack, is ); + recipe.computeVisuals(); + this.arecipes.add( recipe ); + } } } else @@ -84,31 +86,37 @@ public class NEIFacadeRecipeHandler extends TemplateRecipeHandler } @Override - public void loadCraftingRecipes(ItemStack result) + public void loadCraftingRecipes( ItemStack result ) { - if ( result.getItem() == this.ifa ) + if ( result.getItem() == this.facade ) { - CachedShapedRecipe recipe = new CachedShapedRecipe( result ); - recipe.computeVisuals(); - this.arecipes.add( recipe ); + for ( ItemStack anchorStack : this.anchorDefinition.maybeStack( 1 ).asSet() ) + { + CachedShapedRecipe recipe = new CachedShapedRecipe( this.facade, anchorStack, result ); + recipe.computeVisuals(); + this.arecipes.add( recipe ); + } } } @Override - public void loadUsageRecipes(ItemStack ingredient) + public void loadUsageRecipes( ItemStack ingredient ) { - List facades = this.ifa.getFacades(); - for (ItemStack is : facades) + List facades = this.facade.getFacades(); + for ( ItemStack anchorStack : this.anchorDefinition.maybeStack( 1 ).asSet() ) { - CachedShapedRecipe recipe = new CachedShapedRecipe( is ); - - if ( recipe.contains( recipe.ingredients, ingredient.getItem() ) ) + for ( ItemStack is : facades ) { - recipe.computeVisuals(); - if ( recipe.contains( recipe.ingredients, ingredient ) ) + CachedShapedRecipe recipe = new CachedShapedRecipe( this.facade, anchorStack, is ); + + if ( recipe.contains( recipe.ingredients, ingredient.getItem() ) ) { - recipe.setIngredientPermutation( recipe.ingredients, ingredient ); - this.arecipes.add( recipe ); + recipe.computeVisuals(); + if ( recipe.contains( recipe.ingredients, ingredient ) ) + { + recipe.setIngredientPermutation( recipe.ingredients, ingredient ); + this.arecipes.add( recipe ); + } } } } @@ -127,13 +135,19 @@ public class NEIFacadeRecipeHandler extends TemplateRecipeHandler } @Override - public boolean hasOverlay(GuiContainer gui, Container container, int recipe) + public Class getGuiClass() { - return (super.hasOverlay( gui, container, recipe )) || ((this.isRecipe2x2( recipe )) && (RecipeInfo.hasDefaultOverlay( gui, "crafting2x2" ))); + return GuiCrafting.class; } @Override - public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe) + public boolean hasOverlay( GuiContainer gui, Container container, int recipe ) + { + return ( super.hasOverlay( gui, container, recipe ) ) || ( ( this.isRecipe2x2( recipe ) ) && ( RecipeInfo.hasDefaultOverlay( gui, "crafting2x2" ) ) ); + } + + @Override + public IRecipeOverlayRenderer getOverlayRenderer( GuiContainer gui, int recipe ) { IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe ); if ( renderer != null ) @@ -147,7 +161,7 @@ public class NEIFacadeRecipeHandler extends TemplateRecipeHandler } @Override - public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe) + public IOverlayHandler getOverlayHandler( GuiContainer gui, int recipe ) { IOverlayHandler handler = super.getOverlayHandler( gui, recipe ); if ( handler != null ) @@ -156,39 +170,45 @@ public class NEIFacadeRecipeHandler extends TemplateRecipeHandler return RecipeInfo.getOverlayHandler( gui, "crafting2x2" ); } - public boolean isRecipe2x2(int recipe) + public boolean isRecipe2x2( int recipe ) { - for (PositionedStack stack : this.getIngredientStacks( recipe )) + for ( PositionedStack stack : this.getIngredientStacks( recipe ) ) { - if ( (stack.relx > 43) || (stack.rely > 24) ) + if ( ( stack.relx > 43 ) || ( stack.rely > 24 ) ) return false; } return true; } - public class CachedShapedRecipe extends TemplateRecipeHandler.CachedRecipe + @Override + public String getRecipeName() { + return GuiText.FacadeCrafting.getLocal(); + } + private final class CachedShapedRecipe extends TemplateRecipeHandler.CachedRecipe + { public final ArrayList ingredients; public final PositionedStack result; - public CachedShapedRecipe(ItemStack output) { + public CachedShapedRecipe( IFacadeItem facade, ItemStack anchor, ItemStack output ) + { output.stackSize = 4; this.result = new PositionedStack( output, 119, 24 ); this.ingredients = new ArrayList(); - ItemStack in = NEIFacadeRecipeHandler.this.ifa.getTextureItem( output ); - this.setIngredients( 3, 3, new Object[] { null, NEIFacadeRecipeHandler.this.cable_anchor, null, NEIFacadeRecipeHandler.this.cable_anchor, in, NEIFacadeRecipeHandler.this.cable_anchor, null, NEIFacadeRecipeHandler.this.cable_anchor, null } ); + ItemStack in = facade.getTextureItem( output ); + this.setIngredients( 3, 3, new Object[] { null, anchor, null, anchor, in, anchor, null, anchor, null } ); } - public void setIngredients(int width, int height, Object[] items) + public void setIngredients( int width, int height, Object[] items ) { - for (int x = 0; x < width; x++) + for ( int x = 0; x < width; x++ ) { - for (int y = 0; y < height; y++) + for ( int y = 0; y < height; y++ ) { - if ( items[(y * width + x)] != null ) + if ( items[( y * width + x )] != null ) { - ItemStack is = (ItemStack) items[(y * width + x)]; + ItemStack is = (ItemStack) items[( y * width + x )]; PositionedStack stack = new PositionedStack( is, 25 + x * 18, 6 + y * 18, false ); stack.setMaxSize( 1 ); this.ingredients.add( stack ); @@ -197,21 +217,21 @@ public class NEIFacadeRecipeHandler extends TemplateRecipeHandler } } - @Override - public List getIngredients() - { - return this.getCycledIngredients( NEIFacadeRecipeHandler.this.cycleticks / 20, this.ingredients ); - } - @Override public PositionedStack getResult() { return this.result; } + @Override + public List getIngredients() + { + return this.getCycledIngredients( NEIFacadeRecipeHandler.this.cycleticks / 20, this.ingredients ); + } + public void computeVisuals() { - for (PositionedStack p : this.ingredients) + for ( PositionedStack p : this.ingredients ) { p.generatePermutations(); } diff --git a/src/main/java/appeng/integration/modules/NEIHelpers/NEIWorldCraftingHandler.java b/src/main/java/appeng/integration/modules/NEIHelpers/NEIWorldCraftingHandler.java index 361667463..5c1e7e181 100644 --- a/src/main/java/appeng/integration/modules/NEIHelpers/NEIWorldCraftingHandler.java +++ b/src/main/java/appeng/integration/modules/NEIHelpers/NEIWorldCraftingHandler.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; import org.lwjgl.opengl.GL11; @@ -40,7 +41,9 @@ import codechicken.nei.recipe.ICraftingHandler; import codechicken.nei.recipe.IUsageHandler; import appeng.api.AEApi; -import appeng.api.util.AEItemDefinition; +import appeng.api.definitions.IDefinitions; +import appeng.api.definitions.IItemDefinition; +import appeng.api.definitions.IMaterials; import appeng.core.AEConfig; import appeng.core.features.AEFeature; import appeng.core.localization.GuiText; @@ -48,49 +51,64 @@ import appeng.core.localization.GuiText; public class NEIWorldCraftingHandler implements ICraftingHandler, IUsageHandler { - final HashMap details = new HashMap(); - final List offsets = new LinkedList(); - final List outputs = new LinkedList(); + private final Map details = new HashMap(); + private final List offsets = new LinkedList(); + private final List outputs = new LinkedList(); - ItemStack target; + private ItemStack target; - private void addRecipe(AEItemDefinition def, String msg) + private void addRecipe(IItemDefinition def, String msg) { - if ( NEIServerUtils.areStacksSameTypeCrafting( def.stack( 1 ), this.target ) ) + for ( ItemStack definitionStack : def.maybeStack( 1 ).asSet() ) { - this.offsets.add( def ); - this.outputs.add( new PositionedStack( def.stack( 1 ), 75, 4 ) ); - this.details.put( def, msg ); + if ( NEIServerUtils.areStacksSameTypeCrafting( definitionStack, this.target ) ) + { + this.offsets.add( def ); + this.outputs.add( new PositionedStack( definitionStack, 75, 4 ) ); + this.details.put( def, msg ); + } } } private void addRecipes() { + final IDefinitions definitions = AEApi.instance().definitions(); + final IMaterials materials = definitions.materials(); + final String message; if ( AEConfig.instance.isFeatureEnabled( AEFeature.CertusQuartzWorldGen ) ) - this.addRecipe( AEApi.instance().materials().materialCertusQuartzCrystalCharged, - GuiText.ChargedQuartz.getLocal() + "\n\n" + GuiText.ChargedQuartzFind.getLocal() ); + { + message = GuiText.ChargedQuartz.getLocal() + "\n\n" + GuiText.ChargedQuartzFind.getLocal(); + } else - this.addRecipe( AEApi.instance().materials().materialCertusQuartzCrystalCharged, GuiText.ChargedQuartzFind.getLocal() ); + { + message = GuiText.ChargedQuartzFind.getLocal(); + } + + this.addRecipe( materials.certusQuartzCrystalCharged(), message ); if ( AEConfig.instance.isFeatureEnabled( AEFeature.MeteoriteWorldGen ) ) { - this.addRecipe( AEApi.instance().materials().materialLogicProcessorPress, GuiText.inWorldCraftingPresses.getLocal() ); - this.addRecipe( AEApi.instance().materials().materialCalcProcessorPress, GuiText.inWorldCraftingPresses.getLocal() ); - this.addRecipe( AEApi.instance().materials().materialEngProcessorPress, GuiText.inWorldCraftingPresses.getLocal() ); + this.addRecipe( materials.logicProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() ); + this.addRecipe( materials.calcProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() ); + this.addRecipe( materials.engProcessorPress(), GuiText.inWorldCraftingPresses.getLocal() ); } if ( AEConfig.instance.isFeatureEnabled( AEFeature.inWorldFluix ) ) - this.addRecipe( AEApi.instance().materials().materialFluixCrystal, GuiText.inWorldFluix.getLocal() ); + { + this.addRecipe( materials.fluixCrystal(), GuiText.inWorldFluix.getLocal() ); + } if ( AEConfig.instance.isFeatureEnabled( AEFeature.inWorldSingularity ) ) - this.addRecipe( AEApi.instance().materials().materialQESingularity, GuiText.inWorldSingularity.getLocal() ); + { + this.addRecipe( materials.qESingularity(), GuiText.inWorldSingularity.getLocal() ); + } if ( AEConfig.instance.isFeatureEnabled( AEFeature.inWorldPurification ) ) { - this.addRecipe( AEApi.instance().materials().materialPurifiedCertusQuartzCrystal, GuiText.inWorldPurificationCertus.getLocal() ); - this.addRecipe( AEApi.instance().materials().materialPurifiedNetherQuartzCrystal, GuiText.inWorldPurificationNether.getLocal() ); - this.addRecipe( AEApi.instance().materials().materialPurifiedFluixCrystal, GuiText.inWorldPurificationFluix.getLocal() ); + this.addRecipe( materials.purifiedCertusQuartzCrystal(), GuiText.inWorldPurificationCertus.getLocal() ); + this.addRecipe( materials.purifiedNetherQuartzCrystal(), GuiText.inWorldPurificationNether.getLocal() ); + this.addRecipe( materials.purifiedFluixCrystal(), GuiText.inWorldPurificationFluix.getLocal() ); } } diff --git a/src/main/java/appeng/integration/modules/helpers/BSCrate.java b/src/main/java/appeng/integration/modules/helpers/BSCrate.java index fe0495162..f79aac13e 100644 --- a/src/main/java/appeng/integration/modules/helpers/BSCrate.java +++ b/src/main/java/appeng/integration/modules/helpers/BSCrate.java @@ -18,6 +18,7 @@ package appeng.integration.modules.helpers; + import net.mcft.copy.betterstorage.api.crate.ICrateStorage; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; @@ -30,30 +31,25 @@ import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; import appeng.util.item.AEItemStack; + public class BSCrate implements IMEInventory { + private final ICrateStorage crateStorage; + private final ForgeDirection side; - final ICrateStorage cs; - final ForgeDirection side; - - public BSCrate(Object object, ForgeDirection d) { - this.cs = (ICrateStorage) object; + public BSCrate( Object object, ForgeDirection d ) + { + this.crateStorage = (ICrateStorage) object; this.side = d; } @Override - public StorageChannel getChannel() - { - return StorageChannel.ITEMS; - } - - @Override - public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src) + public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src ) { if ( mode == Actionable.SIMULATE ) return null; - ItemStack failed = this.cs.insertItems( input.getItemStack() ); + ItemStack failed = this.crateStorage.insertItems( input.getItemStack() ); if ( failed == null ) return null; input.setStackSize( failed.stackSize ); @@ -61,26 +57,31 @@ public class BSCrate implements IMEInventory } @Override - public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src) + public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src ) { if ( mode == Actionable.SIMULATE ) { - int howMany = this.cs.getItemCount( request.getItemStack() ); + int howMany = this.crateStorage.getItemCount( request.getItemStack() ); return howMany > request.getStackSize() ? request : request.copy().setStackSize( howMany ); } - ItemStack Obtained = this.cs.extractItems( request.getItemStack(), (int) request.getStackSize() ); - return AEItemStack.create( Obtained ); + ItemStack obtained = this.crateStorage.extractItems( request.getItemStack(), (int) request.getStackSize() ); + return AEItemStack.create( obtained ); } @Override - public IItemList getAvailableItems(IItemList out) + public IItemList getAvailableItems( IItemList out ) { - for (ItemStack is : this.cs.getContents()) + for ( ItemStack is : this.crateStorage.getContents() ) { out.add( AEItemStack.create( is ) ); } return out; } + @Override + public StorageChannel getChannel() + { + return StorageChannel.ITEMS; + } } diff --git a/src/main/java/appeng/items/AEBaseItem.java b/src/main/java/appeng/items/AEBaseItem.java index 5d9a10e99..afe1b6c47 100644 --- a/src/main/java/appeng/items/AEBaseItem.java +++ b/src/main/java/appeng/items/AEBaseItem.java @@ -22,12 +22,12 @@ package appeng.items; import java.util.EnumSet; import java.util.List; -import com.google.common.base.Optional; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import com.google.common.base.Optional; + import appeng.core.features.AEFeature; import appeng.core.features.FeatureNameExtractor; import appeng.core.features.IAEFeature; @@ -35,22 +35,22 @@ import appeng.core.features.IFeatureHandler; import appeng.core.features.ItemFeatureHandler; -public class AEBaseItem extends Item implements IAEFeature +public abstract class AEBaseItem extends Item implements IAEFeature { private final String fullName; private final Optional subName; private IFeatureHandler feature; - public AEBaseItem( Class c ) + public AEBaseItem() { - this( c, Optional. absent() ); - this.canRepair = false; + this( Optional. absent() ); + this.setNoRepair(); } - public AEBaseItem( Class c, Optional subName ) + public AEBaseItem( Optional subName ) { this.subName = subName; - this.fullName = new FeatureNameExtractor( c, subName ).get(); + this.fullName = new FeatureNameExtractor( this.getClass(), subName ).get(); } @Override diff --git a/src/main/java/appeng/items/contents/CellUpgrades.java b/src/main/java/appeng/items/contents/CellUpgrades.java index 9e0559171..225b0fa8e 100644 --- a/src/main/java/appeng/items/contents/CellUpgrades.java +++ b/src/main/java/appeng/items/contents/CellUpgrades.java @@ -18,18 +18,20 @@ package appeng.items.contents; + import net.minecraft.item.ItemStack; -import appeng.parts.automation.UpgradeInventory; +import appeng.parts.automation.StackUpgradeInventory; import appeng.util.Platform; -public class CellUpgrades extends UpgradeInventory -{ +public final class CellUpgrades extends StackUpgradeInventory +{ final ItemStack is; - public CellUpgrades(ItemStack is, int upgrades) { - super( is.getItem(), null, upgrades ); + public CellUpgrades( ItemStack is, int upgrades ) + { + super( is, null, upgrades ); this.is = is; this.readFromNBT( Platform.openNbtData( is ), "upgrades" ); } @@ -39,5 +41,4 @@ public class CellUpgrades extends UpgradeInventory { this.writeToNBT( Platform.openNbtData( this.is ), "upgrades" ); } - } \ No newline at end of file diff --git a/src/main/java/appeng/items/materials/ItemMultiMaterial.java b/src/main/java/appeng/items/materials/ItemMultiMaterial.java index 07b34c662..b2a2eb224 100644 --- a/src/main/java/appeng/items/materials/ItemMultiMaterial.java +++ b/src/main/java/appeng/items/materials/ItemMultiMaterial.java @@ -19,7 +19,6 @@ package appeng.items.materials; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; @@ -27,12 +26,11 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.Map.Entry; import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.google.common.collect.ImmutableSet; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -49,70 +47,45 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.OreDictionary; +import com.google.common.collect.ImmutableSet; + import appeng.api.config.Upgrades; import appeng.api.implementations.IUpgradeableHost; import appeng.api.implementations.items.IItemGroup; import appeng.api.implementations.items.IStorageComponent; import appeng.api.implementations.items.IUpgradeModule; +import appeng.api.implementations.tiles.ISegmentedInventory; import appeng.api.parts.IPartHost; import appeng.api.parts.SelectedPart; import appeng.client.texture.MissingIcon; import appeng.core.AEConfig; import appeng.core.features.AEFeature; -import appeng.core.features.AEFeatureHandler; import appeng.core.features.IStackSrc; import appeng.core.features.MaterialStackSrc; +import appeng.core.features.NameResolver; import appeng.items.AEBaseItem; import appeng.util.InventoryAdaptor; import appeng.util.Platform; + public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, IUpgradeModule { - - final HashMap dmgToMaterial = new HashMap(); - + public static final int KILO = 1024; public static ItemMultiMaterial instance; - public ItemMultiMaterial() { - super( ItemMultiMaterial.class ); + private final Map dmgToMaterial = new HashMap(); + private final NameResolver nameResolver; + + public ItemMultiMaterial() + { + this.nameResolver = new NameResolver( this.getClass() ); this.setFeature( EnumSet.of( AEFeature.Core ) ); this.setHasSubtypes( true ); instance = this; } - static class SlightlyBetterSort implements Comparator - { - - final Pattern p; - - public SlightlyBetterSort(Pattern p) { - this.p = p; - } - - @Override - public int compare(String o1, String o2) - { - try - { - Matcher a = this.p.matcher( o1 ); - Matcher b = this.p.matcher( o2 ); - if ( a.find() && b.find() ) - { - int ia = Integer.parseInt( a.group( 1 ) ); - int ib = Integer.parseInt( b.group( 1 ) ); - return Integer.compare( ia, ib ); - } - } - catch (Throwable t) - { - // ek! - } - return o1.compareTo( o2 ); - } - } - @Override - public void addCheckedInformation(ItemStack stack, EntityPlayer player, List lines, boolean displayAdditionalInformation ) + public void addCheckedInformation( ItemStack stack, EntityPlayer player, List lines, boolean displayAdditionalInformation ) { super.addCheckedInformation( stack, player, lines, displayAdditionalInformation ); @@ -130,7 +103,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, if ( u != null ) { List textList = new LinkedList(); - for (Entry j : u.getSupported().entrySet()) + for ( Entry j : u.getSupported().entrySet() ) { String name = null; @@ -141,11 +114,11 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, IItemGroup ig = (IItemGroup) j.getKey().getItem(); String str = ig.getUnlocalizedGroupName( u.getSupported().keySet(), j.getKey() ); if ( str != null ) - name = Platform.gui_localize( str ) + (limit > 1 ? " (" + limit + ')' : ""); + name = Platform.gui_localize( str ) + ( limit > 1 ? " (" + limit + ')' : "" ); } if ( name == null ) - name = j.getKey().getDisplayName() + (limit > 1 ? " (" + limit + ')' : ""); + name = j.getKey().getDisplayName() + ( limit > 1 ? " (" + limit + ')' : "" ); if ( !textList.contains( name ) ) textList.add( name ); @@ -158,12 +131,41 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, } } - public IStackSrc createMaterial(MaterialType mat) + public MaterialType getTypeByStack( ItemStack is ) + { + if ( this.dmgToMaterial.containsKey( is.getItemDamage() ) ) + return this.dmgToMaterial.get( is.getItemDamage() ); + return MaterialType.InvalidType; + } + + @Override + public Upgrades getType( ItemStack itemstack ) + { + switch ( this.getTypeByStack( itemstack ) ) + { + case CardCapacity: + return Upgrades.CAPACITY; + case CardFuzzy: + return Upgrades.FUZZY; + case CardRedstone: + return Upgrades.REDSTONE; + case CardSpeed: + return Upgrades.SPEED; + case CardInverter: + return Upgrades.INVERTER; + case CardCrafting: + return Upgrades.CRAFTING; + default: + return null; + } + } + + public IStackSrc createMaterial( MaterialType mat ) { if ( !mat.isRegistered() ) { boolean enabled = true; - for (AEFeature f : mat.getFeature()) + for ( AEFeature f : mat.getFeature() ) enabled = enabled && AEConfig.instance.isFeatureEnabled( f ); if ( enabled ) @@ -172,17 +174,17 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, int newMaterialNum = mat.damageValue; mat.markReady(); - IStackSrc output = mat.stackSrc = new MaterialStackSrc( mat ); + mat.stackSrc = new MaterialStackSrc( mat ); if ( this.dmgToMaterial.get( newMaterialNum ) == null ) this.dmgToMaterial.put( newMaterialNum, mat ); else throw new RuntimeException( "Meta Overlap detected." ); - return output; + return mat.stackSrc; } - return null; + return mat.stackSrc; } else throw new RuntimeException( "Cannot create the same material twice..." ); @@ -190,7 +192,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, public void makeUnique() { - for (MaterialType mt : ImmutableSet.copyOf( this.dmgToMaterial.values() )) + for ( MaterialType mt : ImmutableSet.copyOf( this.dmgToMaterial.values() ) ) { if ( mt.getOreName() != null ) { @@ -198,15 +200,15 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, String[] names = mt.getOreName().split( "," ); - for (String name : names) + for ( String name : names ) { if ( replacement != null ) break; - ArrayList options = OreDictionary.getOres( name ); + List options = OreDictionary.getOres( name ); if ( options != null && options.size() > 0 ) { - for (ItemStack is : options) + for ( ItemStack is : options ) { if ( is != null && is.getItem() != null ) { @@ -220,7 +222,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, if ( replacement == null || AEConfig.instance.useAEVersion( mt ) ) { // continue using the AE2 item. - for (String name : names) + for ( String name : names ) OreDictionary.registerOre( name, mt.stack( 1 ) ); } else @@ -231,27 +233,25 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, mt.itemInstance = replacement.getItem(); mt.damageValue = replacement.getItemDamage(); } - } } } - public MaterialType getTypeByStack(ItemStack is) - { - if ( this.dmgToMaterial.containsKey( is.getItemDamage() ) ) - return this.dmgToMaterial.get( is.getItemDamage() ); - return MaterialType.InvalidType; - } - @Override - public IIcon getIconFromDamage(int dmg) + public IIcon getIconFromDamage( int dmg ) { if ( this.dmgToMaterial.containsKey( dmg ) ) return this.dmgToMaterial.get( dmg ).IIcon; return new MissingIcon( this ); } - private String nameOf(ItemStack is) + @Override + public String getUnlocalizedName( ItemStack is ) + { + return "item.appliedenergistics2." + this.nameOf( is ); + } + + private String nameOf( ItemStack is ) { if ( is == null ) return "null"; @@ -260,19 +260,34 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, if ( mt == null ) return "null"; - return AEFeatureHandler.getName( ItemMultiMaterial.class, mt.name() ); + return this.nameResolver.getName( mt.name() ); } @Override - public String getUnlocalizedName(ItemStack is) + public void getSubItems( Item par1, CreativeTabs par2CreativeTabs, List cList ) { - return "item.appliedenergistics2." + this.nameOf( is ); + List types = Arrays.asList( MaterialType.values() ); + Collections.sort( types, new Comparator() + { + + @Override + public int compare( MaterialType o1, MaterialType o2 ) + { + return o1.name().compareTo( o2.name() ); + } + } ); + + for ( MaterialType mat : types ) + { + if ( mat.damageValue >= 0 && mat.isRegistered() && mat.itemInstance == this ) + cList.add( new ItemStack( this, 1, mat.damageValue ) ); + } } @Override - public void registerIcons(IIconRegister icoRegister) + public void registerIcons( IIconRegister icoRegister ) { - for (MaterialType mat : MaterialType.values()) + for ( MaterialType mat : MaterialType.values() ) { if ( mat.damageValue != -1 ) { @@ -287,94 +302,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, } @Override - public boolean hasCustomEntity(ItemStack is) - { - return this.getTypeByStack( is ).hasCustomEntity(); - } - - @Override - public Entity createEntity(World w, Entity location, ItemStack itemstack) - { - Class droppedEntity = this.getTypeByStack( itemstack ).getCustomEntityClass(); - Entity eqi; - - try - { - eqi = droppedEntity.getConstructor( World.class, double.class, double.class, double.class, ItemStack.class ).newInstance( w, location.posX, - location.posY, location.posZ, itemstack ); - } - catch (Throwable t) - { - throw new RuntimeException( t ); - } - - eqi.motionX = location.motionX; - eqi.motionY = location.motionY; - eqi.motionZ = location.motionZ; - - if ( location instanceof EntityItem && eqi instanceof EntityItem ) - ((EntityItem) eqi).delayBeforeCanPickup = ((EntityItem) location).delayBeforeCanPickup; - - return eqi; - } - - @Override - public int getBytes(ItemStack is) - { - switch (this.getTypeByStack( is )) - { - case Cell1kPart: - return 1024; - case Cell4kPart: - return 1024 * 4; - case Cell16kPart: - return 1024 * 16; - case Cell64kPart: - return 1024 * 64; - default: - } - return 0; - } - - @Override - public boolean isStorageComponent(ItemStack is) - { - switch (this.getTypeByStack( is )) - { - case Cell1kPart: - case Cell4kPart: - case Cell16kPart: - case Cell64kPart: - return true; - default: - } - return false; - } - - @Override - public Upgrades getType(ItemStack itemstack) - { - switch (this.getTypeByStack( itemstack )) - { - case CardCapacity: - return Upgrades.CAPACITY; - case CardFuzzy: - return Upgrades.FUZZY; - case CardRedstone: - return Upgrades.REDSTONE; - case CardSpeed: - return Upgrades.SPEED; - case CardInverter: - return Upgrades.INVERTER; - case CardCrafting: - return Upgrades.CRAFTING; - default: - return null; - } - } - - @Override - public boolean onItemUseFirst(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + public boolean onItemUseFirst( ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ ) { if ( player.isSneaking() ) { @@ -383,12 +311,12 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, if ( te instanceof IPartHost ) { - SelectedPart sp = ((IPartHost) te).selectPart( Vec3.createVectorHelper( hitX, hitY, hitZ ) ); + SelectedPart sp = ( (IPartHost) te ).selectPart( Vec3.createVectorHelper( hitX, hitY, hitZ ) ); if ( sp.part instanceof IUpgradeableHost ) - upgrades = ((IUpgradeableHost) sp.part).getInventoryByName( "upgrades" ); + upgrades = ( (ISegmentedInventory) sp.part ).getInventoryByName( "upgrades" ); } else if ( te instanceof IUpgradeableHost ) - upgrades = ((IUpgradeableHost) te).getInventoryByName( "upgrades" ); + upgrades = ( (ISegmentedInventory) te ).getInventoryByName( "upgrades" ); if ( upgrades != null && is != null && is.getItem() instanceof IUpgradeModule ) { @@ -414,23 +342,97 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, } @Override - public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List cList) + public boolean hasCustomEntity( ItemStack is ) { - List types = Arrays.asList( MaterialType.values() ); - Collections.sort( types, new Comparator() { + return this.getTypeByStack( is ).hasCustomEntity(); + } - @Override - public int compare(MaterialType o1, MaterialType o2) - { - return o1.name().compareTo( o2.name() ); - } + @Override + public Entity createEntity( World w, Entity location, ItemStack itemstack ) + { + Class droppedEntity = this.getTypeByStack( itemstack ).getCustomEntityClass(); + Entity eqi; - } ); - - for (MaterialType mat : types) + try { - if ( mat.damageValue >= 0 && mat.isRegistered() && mat.itemInstance == this ) - cList.add( new ItemStack( this, 1, mat.damageValue ) ); + eqi = droppedEntity.getConstructor( World.class, double.class, double.class, double.class, ItemStack.class ).newInstance( w, location.posX, location.posY, location.posZ, itemstack ); + } + catch ( Throwable t ) + { + throw new RuntimeException( t ); + } + + eqi.motionX = location.motionX; + eqi.motionY = location.motionY; + eqi.motionZ = location.motionZ; + + if ( location instanceof EntityItem && eqi instanceof EntityItem ) + ( (EntityItem) eqi ).delayBeforeCanPickup = ( (EntityItem) location ).delayBeforeCanPickup; + + return eqi; + } + + @Override + public int getBytes( ItemStack is ) + { + switch ( this.getTypeByStack( is ) ) + { + case Cell1kPart: + return KILO; + case Cell4kPart: + return KILO * 4; + case Cell16kPart: + return KILO * 16; + case Cell64kPart: + return KILO * 64; + default: + } + return 0; + } + + @Override + public boolean isStorageComponent( ItemStack is ) + { + switch ( this.getTypeByStack( is ) ) + { + case Cell1kPart: + case Cell4kPart: + case Cell16kPart: + case Cell64kPart: + return true; + default: + } + return false; + } + + private static class SlightlyBetterSort implements Comparator + { + private final Pattern pattern; + + public SlightlyBetterSort( Pattern pattern ) + { + this.pattern = pattern; + } + + @Override + public int compare( String o1, String o2 ) + { + try + { + Matcher a = this.pattern.matcher( o1 ); + Matcher b = this.pattern.matcher( o2 ); + if ( a.find() && b.find() ) + { + int ia = Integer.parseInt( a.group( 1 ) ); + int ib = Integer.parseInt( b.group( 1 ) ); + return Integer.compare( ia, ib ); + } + } + catch ( Throwable t ) + { + // ek! + } + return o1.compareTo( o2 ); } } } diff --git a/src/main/java/appeng/items/misc/ItemCrystalSeed.java b/src/main/java/appeng/items/misc/ItemCrystalSeed.java index 2a7032a44..2c26a90de 100644 --- a/src/main/java/appeng/items/misc/ItemCrystalSeed.java +++ b/src/main/java/appeng/items/misc/ItemCrystalSeed.java @@ -18,8 +18,10 @@ package appeng.items.misc; + import java.util.EnumSet; import java.util.List; +import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -38,6 +40,7 @@ import net.minecraft.world.World; import cpw.mods.fml.common.registry.EntityRegistry; import appeng.api.AEApi; +import appeng.api.definitions.IMaterials; import appeng.api.implementations.items.IGrowableCrystal; import appeng.api.recipes.ResolverResult; import appeng.core.AppEng; @@ -48,6 +51,7 @@ import appeng.entity.EntityIds; import appeng.items.AEBaseItem; import appeng.util.Platform; + public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal { @@ -63,7 +67,36 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal final IIcon[] fluix = new IIcon[3]; final IIcon[] nether = new IIcon[3]; - private int getProgress(ItemStack is) + public ItemCrystalSeed() + { + this.setHasSubtypes( true ); + this.setFeature( EnumSet.of( AEFeature.Core ) ); + + EntityRegistry.registerModEntity( EntityGrowingCrystal.class, EntityGrowingCrystal.class.getSimpleName(), EntityIds.get( EntityGrowingCrystal.class ), AppEng.instance, 16, 4, true ); + } + + @Nullable + public static ResolverResult getResolver( int certus2 ) + { + ResolverResult resolver = null; + + for ( ItemStack crystalSeedStack : AEApi.instance().definitions().items().crystalSeed().maybeStack( 1 ).asSet() ) + { + crystalSeedStack.setItemDamage( certus2 ); + crystalSeedStack = newStyle( crystalSeedStack ); + resolver = new ResolverResult( "ItemCrystalSeed", crystalSeedStack.getItemDamage(), crystalSeedStack.getTagCompound() ); + } + + return resolver; + } + + private static ItemStack newStyle( ItemStack itemStack ) + { + ( (ItemCrystalSeed) itemStack.getItem() ).getProgress( itemStack ); + return itemStack; + } + + private int getProgress( ItemStack is ) { if ( is.hasTagCompound() ) { @@ -74,35 +107,74 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal int progress; NBTTagCompound comp = Platform.openNbtData( is ); comp.setInteger( "progress", progress = is.getItemDamage() ); - is.setItemDamage( (is.getItemDamage() / SINGLE_OFFSET) * SINGLE_OFFSET ); + is.setItemDamage( ( is.getItemDamage() / SINGLE_OFFSET ) * SINGLE_OFFSET ); return progress; } } - private void setProgress(ItemStack is, int newDamage) + @Nullable + @Override + public ItemStack triggerGrowth( ItemStack is ) + { + int newDamage = this.getProgress( is ) + 1; + final IMaterials materials = AEApi.instance().definitions().materials(); + final int size = is.stackSize; + + if ( newDamage == Certus + SINGLE_OFFSET ) + { + for ( ItemStack quartzStack : materials.purifiedCertusQuartzCrystal().maybeStack( size ).asSet() ) + { + return quartzStack; + } + } + if ( newDamage == Nether + SINGLE_OFFSET ) + { + for ( ItemStack quartzStack : materials.purifiedNetherQuartzCrystal().maybeStack( size ).asSet() ) + { + return quartzStack; + } + } + if ( newDamage == Fluix + SINGLE_OFFSET ) + { + for ( ItemStack quartzStack : materials.purifiedFluixCrystal().maybeStack( size ).asSet() ) + { + return quartzStack; + } + } + if ( newDamage > END ) + return null; + + this.setProgress( is, newDamage ); + return is; + } + + private void setProgress( ItemStack is, int newDamage ) { NBTTagCompound comp = Platform.openNbtData( is ); comp.setInteger( "progress", newDamage ); is.setItemDamage( is.getItemDamage() / LEVEL_OFFSET * LEVEL_OFFSET ); - } - - public ItemCrystalSeed() { - super( ItemCrystalSeed.class ); - this.setHasSubtypes( true ); - this.setFeature( EnumSet.of( AEFeature.Core ) ); - - EntityRegistry.registerModEntity( EntityGrowingCrystal.class, EntityGrowingCrystal.class.getSimpleName(), EntityIds.get( EntityGrowingCrystal.class ), - AppEng.instance, 16, 4, true ); - } - - @Override - public int getEntityLifespan(ItemStack itemStack, World world) + } @Override + public int getEntityLifespan( ItemStack itemStack, World world ) { return Integer.MAX_VALUE; } @Override - public String getUnlocalizedName(ItemStack is) + public float getMultiplier( Block blk, Material mat ) + { + return 0.5f; + } + + @Override + public void addCheckedInformation( ItemStack stack, EntityPlayer player, List lines, boolean displayAdditionalInformation ) + { + lines.add( ButtonToolTips.DoesntDespawn.getLocal() ); + int progress = this.getProgress( stack ) % SINGLE_OFFSET; + lines.add( Math.floor( (float) progress / (float) ( SINGLE_OFFSET / 100 ) ) + "%" ); + + super.addCheckedInformation( stack, player, lines, displayAdditionalInformation ); + } @Override + public String getUnlocalizedName( ItemStack is ) { int damage = this.getProgress( is ); @@ -118,23 +190,7 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal return this.getUnlocalizedName(); } - @Override - public ItemStack triggerGrowth(ItemStack is) - { - int newDamage = this.getProgress( is ) + 1; - if ( newDamage == Certus + SINGLE_OFFSET ) - return AEApi.instance().materials().materialPurifiedCertusQuartzCrystal.stack( is.stackSize ); - if ( newDamage == Nether + SINGLE_OFFSET ) - return AEApi.instance().materials().materialPurifiedNetherQuartzCrystal.stack( is.stackSize ); - if ( newDamage == Fluix + SINGLE_OFFSET ) - return AEApi.instance().materials().materialPurifiedFluixCrystal.stack( is.stackSize ); - if ( newDamage > END ) - return null; - - this.setProgress( is, newDamage ); - return is; - } @Override public boolean isDamageable() @@ -143,35 +199,25 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal } @Override - public void addCheckedInformation(ItemStack stack, EntityPlayer player, List lines, boolean displayAdditionalInformation ) - { - lines.add( ButtonToolTips.DoesntDespawn.getLocal() ); - int progress = this.getProgress( stack ) % SINGLE_OFFSET; - lines.add( Math.floor( (float) progress / (float) (SINGLE_OFFSET / 100) ) + "%" ); - - super.addCheckedInformation( stack, player, lines, displayAdditionalInformation ); - } - - @Override - public boolean isDamaged(ItemStack stack) + public boolean isDamaged( ItemStack stack ) { return false; } @Override - public int getMaxDamage(ItemStack stack) + public int getMaxDamage( ItemStack stack ) { return END; } @Override - public IIcon getIcon(ItemStack stack, int pass) + public IIcon getIcon( ItemStack stack, int pass ) { return this.getIconIndex( stack ); } @Override - public IIcon getIconIndex(ItemStack stack) + public IIcon getIconIndex( ItemStack stack ) { IIcon[] list = null; @@ -204,13 +250,7 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal } @Override - public float getMultiplier(Block blk, Material mat) - { - return 0.5f; - } - - @Override - public void registerIcons(IIconRegister ir) + public void registerIcons( IIconRegister ir ) { String preFix = "appliedenergistics2:ItemCrystalSeed."; @@ -228,13 +268,13 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal } @Override - public boolean hasCustomEntity(ItemStack stack) + public boolean hasCustomEntity( ItemStack stack ) { return true; } @Override - public Entity createEntity(World world, Entity location, ItemStack itemstack) + public Entity createEntity( World world, Entity location, ItemStack itemstack ) { EntityGrowingCrystal egc = new EntityGrowingCrystal( world, location.posX, location.posY, location.posZ, itemstack ); @@ -243,13 +283,13 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal egc.motionZ = location.motionZ; if ( location instanceof EntityItem ) - egc.delayBeforeCanPickup = ((EntityItem) location).delayBeforeCanPickup; + egc.delayBeforeCanPickup = ( (EntityItem) location ).delayBeforeCanPickup; return egc; } @Override - public void getSubItems(Item i, CreativeTabs t, List l) + public void getSubItems( Item i, CreativeTabs t, List l ) { // lvl 0 l.add( newStyle( new ItemStack( this, 1, Certus ) ) ); @@ -267,18 +307,5 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal l.add( newStyle( new ItemStack( this, 1, LEVEL_OFFSET * 2 + Fluix ) ) ); } - private static ItemStack newStyle(ItemStack itemStack) - { - ((ItemCrystalSeed) itemStack.getItem()).getProgress( itemStack ); - return itemStack; - } - - public static ResolverResult getResolver(int certus2) - { - ItemStack is = AEApi.instance().items().itemCrystalSeed.stack( 1 ); - is.setItemDamage( certus2 ); - is = newStyle( is ); - return new ResolverResult( "ItemCrystalSeed", is.getItemDamage(), is.getTagCompound() ); - } } diff --git a/src/main/java/appeng/items/misc/ItemEncodedPattern.java b/src/main/java/appeng/items/misc/ItemEncodedPattern.java index c451f53cc..cf53961eb 100644 --- a/src/main/java/appeng/items/misc/ItemEncodedPattern.java +++ b/src/main/java/appeng/items/misc/ItemEncodedPattern.java @@ -21,6 +21,7 @@ package appeng.items.misc; import java.util.EnumSet; import java.util.List; +import java.util.Map; import java.util.WeakHashMap; import net.minecraft.entity.player.EntityPlayer; @@ -42,18 +43,35 @@ import appeng.helpers.PatternHelper; import appeng.items.AEBaseItem; import appeng.util.Platform; + public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternItem { + // rather simple client side caching. + private static final Map SIMPLE_CACHE = new WeakHashMap(); - public ItemEncodedPattern() { - super( ItemEncodedPattern.class ); + public ItemEncodedPattern() + { this.setFeature( EnumSet.of( AEFeature.Patterns ) ); this.setMaxStackSize( 1 ); if ( Platform.isClient() ) MinecraftForgeClient.registerItemRenderer( this, new ItemEncodedPatternRenderer() ); } - private boolean clearPattern(ItemStack stack, EntityPlayer player) + @Override + public ItemStack onItemRightClick( ItemStack stack, World w, EntityPlayer player ) + { + this.clearPattern( stack, player ); + + return stack; + } + + @Override + public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ ) + { + return this.clearPattern( stack, player ); + } + + private boolean clearPattern( ItemStack stack, EntityPlayer player ) { if ( player.isSneaking() ) { @@ -62,11 +80,15 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt InventoryPlayer inv = player.inventory; - for (int s = 0; s < player.inventory.getSizeInventory(); s++) + for ( int s = 0; s < player.inventory.getSizeInventory(); s++ ) { if ( inv.getStackInSlot( s ) == stack ) { - inv.setInventorySlotContents( s, AEApi.instance().materials().materialBlankPattern.stack( stack.stackSize ) ); + for ( ItemStack blankPattern : AEApi.instance().definitions().materials().blankPattern().maybeStack( stack.stackSize ).asSet() ) + { + inv.setInventorySlotContents( s, blankPattern ); + } + return true; } } @@ -76,20 +98,7 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt } @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { - return this.clearPattern( stack, player ); - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World w, EntityPlayer player) - { - this.clearPattern( stack, player ); - return stack; - } - - @Override - public void addCheckedInformation(ItemStack stack, EntityPlayer player, List lines, boolean displayAdditionalInformation ) + public void addCheckedInformation( ItemStack stack, EntityPlayer player, List lines, boolean displayAdditionalInformation ) { ICraftingPatternDetails details = this.getPatternForItem( stack, player.worldObj ); @@ -104,39 +113,49 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt IAEItemStack[] in = details.getCondensedInputs(); IAEItemStack[] out = details.getCondensedOutputs(); - String label = (isCrafting ? GuiText.Crafts.getLocal() : GuiText.Creates.getLocal()) + ": "; + String label = ( isCrafting ? GuiText.Crafts.getLocal() : GuiText.Creates.getLocal() ) + ": "; String and = ' ' + GuiText.And.getLocal() + ' '; String with = GuiText.With.getLocal() + ": "; boolean first = true; - for (IAEItemStack anOut : out) + for ( IAEItemStack anOut : out ) { if ( anOut == null ) { continue; } - lines.add( (first ? label : and) + anOut.getStackSize() + ' ' + Platform.getItemDisplayName( anOut ) ); + lines.add( ( first ? label : and ) + anOut.getStackSize() + ' ' + Platform.getItemDisplayName( anOut ) ); first = false; } first = true; - for (IAEItemStack anIn : in) + for ( IAEItemStack anIn : in ) { if ( anIn == null ) { continue; } - lines.add( (first ? with : and) + anIn.getStackSize() + ' ' + Platform.getItemDisplayName( anIn ) ); + lines.add( ( first ? with : and ) + anIn.getStackSize() + ' ' + Platform.getItemDisplayName( anIn ) ); first = false; } } - // rather simple client side caching. - static final WeakHashMap SIMPLE_CACHE = new WeakHashMap(); + @Override + public ICraftingPatternDetails getPatternForItem( ItemStack is, World w ) + { + try + { + return new PatternHelper( is, w ); + } + catch ( Throwable t ) + { + return null; + } + } - public ItemStack getOutput(ItemStack item) + public ItemStack getOutput( ItemStack item ) { ItemStack out = SIMPLE_CACHE.get( item ); if ( out != null ) @@ -154,18 +173,4 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt SIMPLE_CACHE.put( item, out = details.getCondensedOutputs()[0].getItemStack() ); return out; } - - @Override - public ICraftingPatternDetails getPatternForItem(ItemStack is, World w) - { - try - { - return new PatternHelper( is, w ); - } - catch (Throwable t) - { - return null; - } - } - } diff --git a/src/main/java/appeng/items/misc/ItemPaintBall.java b/src/main/java/appeng/items/misc/ItemPaintBall.java index 15f1c4b6e..8d715484b 100644 --- a/src/main/java/appeng/items/misc/ItemPaintBall.java +++ b/src/main/java/appeng/items/misc/ItemPaintBall.java @@ -34,33 +34,37 @@ import appeng.core.localization.GuiText; import appeng.items.AEBaseItem; import appeng.util.Platform; + public class ItemPaintBall extends AEBaseItem { - public ItemPaintBall() { - super( ItemPaintBall.class ); + public static final int DAMAGE_THRESHOLD = 20; + + public ItemPaintBall() + { this.setFeature( EnumSet.of( AEFeature.PaintBalls ) ); - this.hasSubtypes = true; + this.setHasSubtypes( true ); + if ( Platform.isClient() ) MinecraftForgeClient.registerItemRenderer( this, new PaintBallRender() ); } @Override - public String getItemStackDisplayName(ItemStack is) + public String getItemStackDisplayName( ItemStack is ) { return super.getItemStackDisplayName( is ) + " - " + this.getExtraName( is ); } - public String getExtraName(ItemStack is) + public String getExtraName( ItemStack is ) { - return (is.getItemDamage() >= 20 ? GuiText.Lumen.getLocal() + ' ' : "") + this.getColor( is ); + return ( is.getItemDamage() >= DAMAGE_THRESHOLD ? GuiText.Lumen.getLocal() + ' ' : "" ) + this.getColor( is ); } - public AEColor getColor(ItemStack is) + public AEColor getColor( ItemStack is ) { int dmg = is.getItemDamage(); - if ( dmg >= 20 ) - dmg -= 20; + if ( dmg >= DAMAGE_THRESHOLD ) + dmg -= DAMAGE_THRESHOLD; if ( dmg >= AEColor.values().length ) return AEColor.Transparent; @@ -69,21 +73,20 @@ public class ItemPaintBall extends AEBaseItem } @Override - public void getSubItems(Item i, CreativeTabs ct, List l) + public void getSubItems( Item i, CreativeTabs ct, List l ) { - for (AEColor c : AEColor.values()) + for ( AEColor c : AEColor.values() ) if ( c != AEColor.Transparent ) l.add( new ItemStack( this, 1, c.ordinal() ) ); - for (AEColor c : AEColor.values()) + for ( AEColor c : AEColor.values() ) if ( c != AEColor.Transparent ) - l.add( new ItemStack( this, 1, 20 + c.ordinal() ) ); + l.add( new ItemStack( this, 1, DAMAGE_THRESHOLD + c.ordinal() ) ); } - public boolean isLumen(ItemStack is) + public boolean isLumen( ItemStack is ) { int dmg = is.getItemDamage(); - return dmg >= 20; + return dmg >= DAMAGE_THRESHOLD; } - } diff --git a/src/main/java/appeng/items/parts/ItemFacade.java b/src/main/java/appeng/items/parts/ItemFacade.java index e9add328c..e6f35f1ae 100644 --- a/src/main/java/appeng/items/parts/ItemFacade.java +++ b/src/main/java/appeng/items/parts/ItemFacade.java @@ -18,6 +18,7 @@ package appeng.items.parts; + import java.util.ArrayList; import java.util.EnumSet; import java.util.List; @@ -42,6 +43,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import appeng.api.AEApi; +import appeng.api.exceptions.MissingDefinition; import appeng.api.parts.IAlphaPassItem; import appeng.block.solids.OreQuartz; import appeng.client.render.BusRenderer; @@ -52,11 +54,14 @@ import appeng.facade.IFacadeItem; import appeng.items.AEBaseItem; import appeng.util.Platform; + public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassItem { - public ItemFacade() { - super( ItemFacade.class ); + private List subTypes = null; + + public ItemFacade() + { this.setFeature( EnumSet.of( AEFeature.Facades ) ); this.setHasSubtypes( true ); if ( Platform.isClient() ) @@ -64,20 +69,46 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte } @Override - @SideOnly(Side.CLIENT) + @SideOnly( Side.CLIENT ) public int getSpriteNumber() { return 0; } @Override - public boolean onItemUse(ItemStack is, EntityPlayer player, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + public boolean onItemUse( ItemStack is, EntityPlayer player, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ ) { return AEApi.instance().partHelper().placeBus( is, x, y, z, side, player, w ); } @Override - public FacadePart createPartFromItemStack(ItemStack is, ForgeDirection side) + public String getItemStackDisplayName( ItemStack is ) + { + try + { + ItemStack in = this.getTextureItem( is ); + if ( in != null ) + { + return super.getItemStackDisplayName( is ) + " - " + in.getDisplayName(); + } + } + catch ( Throwable ignored ) + { + + } + + return super.getItemStackDisplayName( is ); + } + + @Override + public void getSubItems( Item number, CreativeTabs tab, List list ) + { + this.calculateSubTypes(); + list.addAll( this.subTypes ); + } + + @Override + public FacadePart createPartFromItemStack( ItemStack is, ForgeDirection side ) { ItemStack in = this.getTextureItem( is ); if ( in != null ) @@ -85,40 +116,8 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte return null; } - List subTypes = null; - - public List getFacades() - { - this.calculateSubTypes(); - return this.subTypes; - } - - public ItemStack getCreativeTabIcon() - { - this.calculateSubTypes(); - if ( this.subTypes.isEmpty() ) - return new ItemStack( Items.cake ); - return this.subTypes.get( 0 ); - } - @Override - public void getSubItems(Item number, CreativeTabs tab, List list) - { - this.calculateSubTypes(); - list.addAll( this.subTypes ); - } - - public ItemStack createFromIDs(int[] ids) - { - ItemStack is = new ItemStack( AEApi.instance().items().itemFacade.item() ); - NBTTagCompound data = new NBTTagCompound(); - data.setIntArray( "x", ids.clone() ); - is.setTagCompound( data ); - return is; - } - - @Override - public ItemStack getTextureItem(ItemStack is) + public ItemStack getTextureItem( ItemStack is ) { Block blk = this.getBlock( is ); if ( blk != null ) @@ -126,12 +125,51 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte return null; } + @Override + public int getMeta( ItemStack is ) + { + NBTTagCompound data = is.getTagCompound(); + if ( data != null ) + { + int[] blk = data.getIntArray( "x" ); + if ( blk != null && blk.length == 2 ) + return blk[1]; + } + return 0; + } + + @Override + public Block getBlock( ItemStack is ) + { + NBTTagCompound data = is.getTagCompound(); + if ( data != null ) + { + if ( data.hasKey( "modid" ) && data.hasKey( "itemname" ) ) + { + return GameRegistry.findBlock( data.getString( "modid" ), data.getString( "itemname" ) ); + } + else + { + int[] blk = data.getIntArray( "x" ); + if ( blk != null && blk.length == 2 ) + return Block.getBlockById( blk[0] ); + } + } + return Blocks.glass; + } + + public List getFacades() + { + this.calculateSubTypes(); + return this.subTypes; + } + private void calculateSubTypes() { if ( this.subTypes == null ) { this.subTypes = new ArrayList(); - for (Object blk : Block.blockRegistry) + for ( Object blk : Block.blockRegistry ) { Block b = (Block) blk; try @@ -140,14 +178,14 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte List tmpList = new ArrayList(); b.getSubBlocks( item, b.getCreativeTabToDisplayOn(), tmpList ); - for (ItemStack l : tmpList) + for ( ItemStack l : tmpList ) { ItemStack facade = this.createFacadeForItem( l, false ); if ( facade != null ) this.subTypes.add( facade ); } } - catch (Throwable t) + catch ( Throwable t ) { // just absorb.. } @@ -156,10 +194,9 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte if ( FacadeConfig.instance.hasChanged() ) FacadeConfig.instance.save(); } - } - public ItemStack createFacadeForItem(ItemStack l, boolean returnItem) + public ItemStack createFacadeForItem( ItemStack l, boolean returnItem ) { if ( l == null ) return null; @@ -174,7 +211,7 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte boolean enableGlass = b instanceof BlockGlass || b instanceof BlockStainedGlass; boolean disableOre = b instanceof OreQuartz; - boolean defaultValue = (b.isOpaqueCube() && !b.getTickRandomly() && !hasTile && !disableOre) || enableGlass; + boolean defaultValue = ( b.isOpaqueCube() && !b.getTickRandomly() && !hasTile && !disableOre ) || enableGlass; if ( FacadeConfig.instance.checkEnabled( b, metadata, defaultValue ) ) { if ( returnItem ) @@ -195,60 +232,30 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte return null; } - @Override - public Block getBlock(ItemStack is) + public ItemStack getCreativeTabIcon() { - NBTTagCompound data = is.getTagCompound(); - if ( data != null ) + this.calculateSubTypes(); + if ( this.subTypes.isEmpty() ) + return new ItemStack( Items.cake ); + return this.subTypes.get( 0 ); + } + + public ItemStack createFromIDs( int[] ids ) + { + for ( ItemStack facadeStack : AEApi.instance().definitions().items().facade().maybeStack( 1 ).asSet() ) { - if ( data.hasKey( "modid" ) && data.hasKey( "itemname" ) ) - { - return GameRegistry.findBlock( data.getString( "modid" ), data.getString( "itemname" ) ); - } - else - { - int[] blk = data.getIntArray( "x" ); - if ( blk != null && blk.length == 2 ) - return Block.getBlockById( blk[0] ); - } + NBTTagCompound facadeTag = new NBTTagCompound(); + facadeTag.setIntArray( "x", ids.clone() ); + facadeStack.setTagCompound( facadeTag ); + + return facadeStack; } - return Blocks.glass; + + throw new MissingDefinition( "Tried to create a facade, while facades are being deactivated." ); } @Override - public int getMeta(ItemStack is) - { - NBTTagCompound data = is.getTagCompound(); - if ( data != null ) - { - int[] blk = data.getIntArray( "x" ); - if ( blk != null && blk.length == 2 ) - return blk[1]; - } - return 0; - } - - @Override - public String getItemStackDisplayName(ItemStack is) - { - try - { - ItemStack in = this.getTextureItem( is ); - if ( in != null ) - { - return super.getItemStackDisplayName( is ) + " - " + in.getDisplayName(); - } - } - catch (Throwable ignored) - { - - } - - return super.getItemStackDisplayName( is ); - } - - @Override - public boolean useAlphaPass(ItemStack is) + public boolean useAlphaPass( ItemStack is ) { ItemStack out = this.getTextureItem( is ); @@ -261,5 +268,4 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte return false; } - } diff --git a/src/main/java/appeng/items/parts/ItemMultiPart.java b/src/main/java/appeng/items/parts/ItemMultiPart.java index f5ad2347f..109e1c2f7 100644 --- a/src/main/java/appeng/items/parts/ItemMultiPart.java +++ b/src/main/java/appeng/items/parts/ItemMultiPart.java @@ -24,9 +24,12 @@ import java.util.Comparator; import java.util.EnumSet; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import javax.annotation.Nullable; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -41,40 +44,80 @@ import cpw.mods.fml.relauncher.SideOnly; import appeng.api.AEApi; import appeng.api.implementations.items.IItemGroup; import appeng.api.parts.IPart; +import appeng.api.parts.IPartHelper; import appeng.api.parts.IPartItem; +import appeng.api.util.AEColor; import appeng.core.AEConfig; import appeng.core.AELog; import appeng.core.features.AEFeature; -import appeng.core.features.AEFeatureHandler; +import appeng.core.features.NameResolver; import appeng.core.features.ItemStackSrc; import appeng.core.localization.GuiText; import appeng.items.AEBaseItem; public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup { + private final NameResolver nameResolver; - static class PartTypeIst + private static class PartTypeIst { - - PartType part; - int variant; + private PartType part; + private int variant; @SideOnly(Side.CLIENT) - IIcon ico; + private IIcon ico; } - final HashMap dmgToPart = new HashMap(); + private final Map dmgToPart = new HashMap(); public static ItemMultiPart instance; - public ItemMultiPart() { - super( ItemMultiPart.class ); + public ItemMultiPart( IPartHelper partHelper ) { + this.nameResolver = new NameResolver( this.getClass() ); this.setFeature( EnumSet.of( AEFeature.Core ) ); - AEApi.instance().partHelper().setItemBusRenderer( this ); + partHelper.setItemBusRenderer( this ); this.setHasSubtypes( true ); instance = this; } + public final ItemStackSrc createPart( PartType mat ) + { + int varID = 0; + + // verify + for (PartTypeIst p : this.dmgToPart.values()) + { + if ( p.part == mat && p.variant == varID ) + throw new RuntimeException( "Cannot create the same material twice..." ); + } + + boolean enabled = true; + for (AEFeature f : mat.getFeature()) + enabled = enabled && AEConfig.instance.isFeatureEnabled( f ); + + int newPartNum = mat.baseDamage + varID; + ItemStackSrc output = new ItemStackSrc( this, newPartNum ); + + if ( enabled ) + { + PartTypeIst pti = new PartTypeIst(); + pti.part = mat; + pti.variant = varID; + + if ( this.dmgToPart.get( newPartNum ) == null ) + { + this.dmgToPart.put( newPartNum, pti ); + return output; + } + else + { + throw new RuntimeException( "Meta Overlap detected." ); + } + } + + return output; + } + public ItemStackSrc createPart(PartType mat, Enum variant) { try @@ -86,6 +129,7 @@ public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup catch (Throwable e) { AELog.integration( e ); + e.printStackTrace(); return null; // part not supported.. } @@ -133,6 +177,7 @@ public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup return -1; } + @Nullable public PartType getTypeByStack(ItemStack is) { if ( is == null ) @@ -166,7 +211,7 @@ public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup public String getName(ItemStack is) { - return AEFeatureHandler.getName( ItemMultiPart.class, this.getTypeByStack( is ).name() ); + return this.nameResolver.getName( this.getTypeByStack( is ).name() ); } @Override @@ -176,10 +221,12 @@ public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup if ( pt == null ) return "Unnamed"; - Enum[] variants = pt.getVariants(); + if ( pt.isCable() ) + { + final AEColor[] variants = AEColor.values(); - if ( variants != null ) return super.getItemStackDisplayName( is ) + " - " + variants[this.dmgToPart.get( is.getItemDamage() ).variant].toString(); + } if ( pt.getExtraName() != null ) return super.getItemStackDisplayName( is ) + " - " + pt.getExtraName().getLocal(); diff --git a/src/main/java/appeng/items/parts/PartType.java b/src/main/java/appeng/items/parts/PartType.java index 31e77f1e3..236ba93d3 100644 --- a/src/main/java/appeng/items/parts/PartType.java +++ b/src/main/java/appeng/items/parts/PartType.java @@ -23,7 +23,6 @@ import java.lang.reflect.Constructor; import java.util.EnumSet; import appeng.api.parts.IPart; -import appeng.api.util.AEColor; import appeng.core.features.AEFeature; import appeng.core.localization.GuiText; import appeng.parts.automation.PartAnnihilationPlane; @@ -61,95 +60,121 @@ import appeng.parts.reporting.PartTerminal; public enum PartType { - InvalidType( -1, AEFeature.Core, null ), + InvalidType( -1, EnumSet.of( AEFeature.Core ), null ), - CableGlass( 0, AEFeature.Core, PartCableGlass.class ), + CableGlass( 0, EnumSet.of( AEFeature.Core ), PartCableGlass.class ) + { + @Override + public boolean isCable() + { + return true; + } + }, - CableCovered( 20, AEFeature.Core, PartCableCovered.class ), + CableCovered( 20, EnumSet.of( AEFeature.Core ), PartCableCovered.class ) + { + @Override + public boolean isCable() + { + return true; + } + }, - CableSmart( 40, AEFeature.Channels, PartCableSmart.class ), + CableSmart( 40, EnumSet.of( AEFeature.Channels ), PartCableSmart.class ) + { + @Override + public boolean isCable() + { + return true; + } + }, - CableDense( 60, AEFeature.Channels, PartDenseCable.class ), + CableDense( 60, EnumSet.of( AEFeature.Channels ), PartDenseCable.class ) + { + @Override + public boolean isCable() + { + return true; + } + }, - ToggleBus( 80, AEFeature.Core, PartToggleBus.class ), + ToggleBus( 80, EnumSet.of( AEFeature.Core ), PartToggleBus.class ), - InvertedToggleBus( 100, AEFeature.Core, PartInvertedToggleBus.class ), + InvertedToggleBus( 100, EnumSet.of( AEFeature.Core ), PartInvertedToggleBus.class ), - CableAnchor( 120, AEFeature.Core, PartCableAnchor.class ), + CableAnchor( 120, EnumSet.of( AEFeature.Core ), PartCableAnchor.class ), - QuartzFiber( 140, AEFeature.Core, PartQuartzFiber.class ), + QuartzFiber( 140, EnumSet.of( AEFeature.Core ), PartQuartzFiber.class ), - Monitor( 160, AEFeature.Core, PartMonitor.class ), + Monitor( 160, EnumSet.of( AEFeature.Core ), PartMonitor.class ), - SemiDarkMonitor( 180, AEFeature.Core, PartSemiDarkMonitor.class ), + SemiDarkMonitor( 180, EnumSet.of( AEFeature.Core ), PartSemiDarkMonitor.class ), - DarkMonitor( 200, AEFeature.Core, PartDarkMonitor.class ), + DarkMonitor( 200, EnumSet.of( AEFeature.Core ), PartDarkMonitor.class ), - StorageBus( 220, AEFeature.StorageBus, PartStorageBus.class ), + StorageBus( 220, EnumSet.of( AEFeature.StorageBus ), PartStorageBus.class ), - ImportBus( 240, AEFeature.ImportBus, PartImportBus.class ), + ImportBus( 240, EnumSet.of( AEFeature.ImportBus ), PartImportBus.class ), - ExportBus( 260, AEFeature.ExportBus, PartExportBus.class ), + ExportBus( 260, EnumSet.of( AEFeature.ExportBus ), PartExportBus.class ), - LevelEmitter( 280, AEFeature.LevelEmitter, PartLevelEmitter.class ), + LevelEmitter( 280, EnumSet.of( AEFeature.LevelEmitter ), PartLevelEmitter.class ), - AnnihilationPlane( 300, AEFeature.AnnihilationPlane, PartAnnihilationPlane.class ), + AnnihilationPlane( 300, EnumSet.of( AEFeature.AnnihilationPlane ), PartAnnihilationPlane.class ), - FormationPlane( 320, AEFeature.FormationPlane, PartFormationPlane.class ), + FormationPlane( 320, EnumSet.of( AEFeature.FormationPlane ), PartFormationPlane.class ), - PatternTerminal( 340, AEFeature.Patterns, PartPatternTerminal.class ), + PatternTerminal( 340, EnumSet.of( AEFeature.Patterns ), PartPatternTerminal.class ), - CraftingTerminal( 360, AEFeature.CraftingTerminal, PartCraftingTerminal.class ), + CraftingTerminal( 360, EnumSet.of( AEFeature.CraftingTerminal ), PartCraftingTerminal.class ), - Terminal( 380, AEFeature.Core, PartTerminal.class ), + Terminal( 380, EnumSet.of( AEFeature.Core ), PartTerminal.class ), - StorageMonitor( 400, AEFeature.StorageMonitor, PartStorageMonitor.class ), + StorageMonitor( 400, EnumSet.of( AEFeature.StorageMonitor ), PartStorageMonitor.class ), - ConversionMonitor( 420, AEFeature.PartConversionMonitor, PartConversionMonitor.class ), + ConversionMonitor( 420, EnumSet.of( AEFeature.PartConversionMonitor ), PartConversionMonitor.class ), - Interface( 440, AEFeature.Core, PartInterface.class ), + Interface( 440, EnumSet.of( AEFeature.Core ), PartInterface.class ), - P2PTunnelME( 460, AEFeature.P2PTunnelME, PartP2PTunnelME.class, GuiText.METunnel ), + P2PTunnelME( 460, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelME ), PartP2PTunnelME.class, GuiText.METunnel ), - P2PTunnelRedstone( 461, AEFeature.P2PTunnelRedstone, PartP2PRedstone.class, GuiText.RedstoneTunnel ), + P2PTunnelRedstone( 461, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelRedstone ), PartP2PRedstone.class, GuiText.RedstoneTunnel ), - P2PTunnelItems( 462, AEFeature.P2PTunnelItems, PartP2PItems.class, GuiText.ItemTunnel ), + P2PTunnelItems( 462, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelItems ), PartP2PItems.class, GuiText.ItemTunnel ), - P2PTunnelLiquids( 463, AEFeature.P2PTunnelLiquids, PartP2PLiquids.class, GuiText.FluidTunnel ), + P2PTunnelLiquids( 463, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelLiquids ), PartP2PLiquids.class, GuiText.FluidTunnel ), - P2PTunnelEU( 465, AEFeature.P2PTunnelEU, PartP2PIC2Power.class, GuiText.EUTunnel ), + P2PTunnelEU( 465, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelEU ), PartP2PIC2Power.class, GuiText.EUTunnel ), - P2PTunnelRF( 466, AEFeature.P2PTunnelRF, PartP2PRFPower.class, GuiText.RFTunnel ), + P2PTunnelRF( 466, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelRF ), PartP2PRFPower.class, GuiText.RFTunnel ), - P2PTunnelLight( 467, AEFeature.P2PTunnelLight, PartP2PLight.class, GuiText.LightTunnel ), + P2PTunnelLight( 467, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelLight ), PartP2PLight.class, GuiText.LightTunnel ), - InterfaceTerminal( 480, AEFeature.InterfaceTerminal, PartInterfaceTerminal.class ); + InterfaceTerminal( 480, EnumSet.of( AEFeature.InterfaceTerminal ), PartInterfaceTerminal.class ); - public final int baseDamage; private final EnumSet features; private final Class myPart; private final GuiText extraName; + public final int baseDamage; + public Constructor constructor; - PartType( int baseMetaValue, AEFeature part, Class c ) + PartType( int baseMetaValue, EnumSet features, Class c ) { - this( baseMetaValue, part, c, null ); + this( baseMetaValue, features, c, null ); } - PartType( int baseMetaValue, AEFeature part, Class c, GuiText en ) + PartType( int baseMetaValue, EnumSet features, Class c, GuiText en ) { - this.features = EnumSet.of( part ); + this.features = features; this.myPart = c; this.extraName = en; this.baseDamage = baseMetaValue; } - public Enum[] getVariants() + public boolean isCable() { - if ( this == CableSmart || this == CableCovered || this == CableGlass || this == CableDense ) - return AEColor.values(); - - return null; + return false; } public EnumSet getFeature() diff --git a/src/main/java/appeng/items/storage/ItemBasicStorageCell.java b/src/main/java/appeng/items/storage/ItemBasicStorageCell.java index 60be9666f..ea026dcf5 100644 --- a/src/main/java/appeng/items/storage/ItemBasicStorageCell.java +++ b/src/main/java/appeng/items/storage/ItemBasicStorageCell.java @@ -23,8 +23,6 @@ import java.util.EnumSet; import java.util.List; import java.util.Set; -import com.google.common.base.Optional; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; @@ -32,9 +30,12 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import com.google.common.base.Optional; + import appeng.api.AEApi; import appeng.api.config.FuzzyMode; import appeng.api.config.IncludeExclude; +import appeng.api.exceptions.MissingDefinition; import appeng.api.implementations.items.IItemGroup; import appeng.api.implementations.items.IStorageCell; import appeng.api.storage.ICellInventory; @@ -63,7 +64,7 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II public ItemBasicStorageCell( MaterialType whichCell, int kilobytes ) { - super( ItemBasicStorageCell.class, Optional.of( kilobytes + "k" ) ); + super( Optional.of( kilobytes + "k" ) ); this.setFeature( EnumSet.of( AEFeature.StorageCells ) ); this.setMaxStackSize( 1 ); @@ -240,13 +241,18 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II playerInventory.setInventorySlotContents( playerInventory.currentItem, null ); ItemStack extraB = ia.addItems( this.component.stack( 1 ) ); - ItemStack extraA = ia.addItems( AEApi.instance().materials().materialEmptyStorageCell.stack( 1 ) ); - - if ( extraA != null ) - player.dropPlayerItemWithRandomChoice( extraA, false ); if ( extraB != null ) player.dropPlayerItemWithRandomChoice( extraB, false ); + for ( ItemStack storageCellStack : AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).asSet() ) + { + final ItemStack extraA = ia.addItems( storageCellStack ); + if ( extraA != null ) + { + player.dropPlayerItemWithRandomChoice( extraA, false ); + } + } + if ( player.inventoryContainer != null ) player.inventoryContainer.detectAndSendChanges(); @@ -266,7 +272,12 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II @Override public ItemStack getContainerItem( ItemStack itemStack ) { - return AEApi.instance().materials().materialEmptyStorageCell.stack( 1 ); + for ( ItemStack stack : AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).asSet() ) + { + return stack; + } + + throw new MissingDefinition( "Tried to use empty storage cells while basic storage cells are defined." ); } @Override diff --git a/src/main/java/appeng/items/storage/ItemCreativeStorageCell.java b/src/main/java/appeng/items/storage/ItemCreativeStorageCell.java index b39e3398e..7f1eb4a19 100644 --- a/src/main/java/appeng/items/storage/ItemCreativeStorageCell.java +++ b/src/main/java/appeng/items/storage/ItemCreativeStorageCell.java @@ -18,6 +18,7 @@ package appeng.items.storage; + import java.util.EnumSet; import net.minecraft.inventory.IInventory; @@ -29,41 +30,42 @@ import appeng.core.features.AEFeature; import appeng.items.AEBaseItem; import appeng.items.contents.CellConfig; + public class ItemCreativeStorageCell extends AEBaseItem implements ICellWorkbenchItem { - public ItemCreativeStorageCell() { - super( ItemCreativeStorageCell.class ); + public ItemCreativeStorageCell() + { this.setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.Creative ) ); this.setMaxStackSize( 1 ); } @Override - public boolean isEditable(ItemStack is) + public boolean isEditable( ItemStack is ) { return true; } @Override - public IInventory getUpgradesInventory(ItemStack is) + public IInventory getUpgradesInventory( ItemStack is ) { return null; } @Override - public IInventory getConfigInventory(ItemStack is) + public IInventory getConfigInventory( ItemStack is ) { return new CellConfig( is ); } @Override - public FuzzyMode getFuzzyMode(ItemStack is) + public FuzzyMode getFuzzyMode( ItemStack is ) { return FuzzyMode.IGNORE_ALL; } @Override - public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) + public void setFuzzyMode( ItemStack is, FuzzyMode fzMode ) { } diff --git a/src/main/java/appeng/items/storage/ItemSpatialStorageCell.java b/src/main/java/appeng/items/storage/ItemSpatialStorageCell.java index 1895a951a..7bfecc16c 100644 --- a/src/main/java/appeng/items/storage/ItemSpatialStorageCell.java +++ b/src/main/java/appeng/items/storage/ItemSpatialStorageCell.java @@ -22,14 +22,14 @@ package appeng.items.storage; import java.util.EnumSet; import java.util.List; -import com.google.common.base.Optional; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; +import com.google.common.base.Optional; + import appeng.api.implementations.TransitionResult; import appeng.api.implementations.items.ISpatialStorageCell; import appeng.api.util.WorldCoord; @@ -37,7 +37,6 @@ import appeng.core.WorldSettings; import appeng.core.features.AEFeature; import appeng.core.localization.GuiText; import appeng.items.AEBaseItem; -import appeng.items.materials.MaterialType; import appeng.spatial.StorageHelper; import appeng.spatial.StorageWorldProvider; import appeng.util.Platform; @@ -45,17 +44,14 @@ import appeng.util.Platform; public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorageCell { + private final int maxRegion; - final MaterialType component; - final int maxRegion; - - public ItemSpatialStorageCell( MaterialType whichCell, int spatialScale ) + public ItemSpatialStorageCell( int spatialScale ) { - super( ItemSpatialStorageCell.class, Optional.of( spatialScale + "Cubed" ) ); + super( Optional.of( spatialScale + "Cubed" ) ); this.setFeature( EnumSet.of( AEFeature.SpatialIO ) ); this.setMaxStackSize( 1 ); this.maxRegion = spatialScale; - this.component = whichCell; } @Override diff --git a/src/main/java/appeng/items/storage/ItemViewCell.java b/src/main/java/appeng/items/storage/ItemViewCell.java index 027126d4f..773504c8e 100644 --- a/src/main/java/appeng/items/storage/ItemViewCell.java +++ b/src/main/java/appeng/items/storage/ItemViewCell.java @@ -18,6 +18,7 @@ package appeng.items.storage; + import java.util.EnumSet; import net.minecraft.inventory.IInventory; @@ -41,102 +42,61 @@ import appeng.util.prioitylist.IPartitionList; import appeng.util.prioitylist.MergedPriorityList; import appeng.util.prioitylist.PrecisePriorityList; + public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem { - public ItemViewCell() { - super( ItemViewCell.class ); this.setFeature( EnumSet.of( AEFeature.Core ) ); this.setMaxStackSize( 1 ); } - @Override - public boolean isEditable(ItemStack is) - { - return true; - } - - @Override - public IInventory getUpgradesInventory(ItemStack is) - { - return new CellUpgrades( is, 2 ); - } - - @Override - public IInventory getConfigInventory(ItemStack is) - { - return new CellConfig( is ); - } - - @Override - public FuzzyMode getFuzzyMode(ItemStack is) - { - String fz = Platform.openNbtData( is ).getString( "FuzzyMode" ); - try - { - return FuzzyMode.valueOf( fz ); - } - catch (Throwable t) - { - return FuzzyMode.IGNORE_ALL; - } - } - - @Override - public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) - { - Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() ); - } - - public static IPartitionList createFilter(ItemStack[] list) + public static IPartitionList createFilter( ItemStack[] list ) { IPartitionList myPartitionList = null; MergedPriorityList myMergedList = new MergedPriorityList(); - for (ItemStack currentViewCell : list) + for ( ItemStack currentViewCell : list ) { if ( currentViewCell == null ) continue; - if ( (currentViewCell.getItem() instanceof ItemViewCell) ) + if ( ( currentViewCell.getItem() instanceof ItemViewCell ) ) { - boolean hasInverter = false; - boolean hasFuzzy = false; IItemList priorityList = AEApi.instance().storage().createItemList(); - ItemViewCell vc = (ItemViewCell) currentViewCell.getItem(); + ICellWorkbenchItem vc = (ICellWorkbenchItem) currentViewCell.getItem(); IInventory upgrades = vc.getUpgradesInventory( currentViewCell ); IInventory config = vc.getConfigInventory( currentViewCell ); FuzzyMode fzMode = vc.getFuzzyMode( currentViewCell ); - hasInverter = false; - hasFuzzy = false; + boolean hasInverter = false; + boolean hasFuzzy = false; - for (int x = 0; x < upgrades.getSizeInventory(); x++) + for ( int x = 0; x < upgrades.getSizeInventory(); x++ ) { ItemStack is = upgrades.getStackInSlot( x ); if ( is != null && is.getItem() instanceof IUpgradeModule ) { - Upgrades u = ((IUpgradeModule) is.getItem()).getType( is ); + Upgrades u = ( (IUpgradeModule) is.getItem() ).getType( is ); if ( u != null ) { - switch (u) + switch ( u ) { - case FUZZY: - hasFuzzy = true; - break; - case INVERTER: - hasInverter = true; - break; - default: + case FUZZY: + hasFuzzy = true; + break; + case INVERTER: + hasInverter = true; + break; + default: } } } } - for (int x = 0; x < config.getSizeInventory(); x++) + for ( int x = 0; x < config.getSizeInventory(); x++ ) { ItemStack is = config.getStackInSlot( x ); if ( is != null ) @@ -157,4 +117,42 @@ public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem return myPartitionList; } + + @Override + public boolean isEditable( ItemStack is ) + { + return true; + } + + @Override + public IInventory getUpgradesInventory( ItemStack is ) + { + return new CellUpgrades( is, 2 ); + } + + @Override + public IInventory getConfigInventory( ItemStack is ) + { + return new CellConfig( is ); + } + + @Override + public FuzzyMode getFuzzyMode( ItemStack is ) + { + String fz = Platform.openNbtData( is ).getString( "FuzzyMode" ); + try + { + return FuzzyMode.valueOf( fz ); + } + catch ( Throwable t ) + { + return FuzzyMode.IGNORE_ALL; + } + } + + @Override + public void setFuzzyMode( ItemStack is, FuzzyMode fzMode ) + { + Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() ); + } } diff --git a/src/main/java/appeng/items/tools/ToolBiometricCard.java b/src/main/java/appeng/items/tools/ToolBiometricCard.java index ba5565b53..ae332b087 100644 --- a/src/main/java/appeng/items/tools/ToolBiometricCard.java +++ b/src/main/java/appeng/items/tools/ToolBiometricCard.java @@ -18,11 +18,10 @@ package appeng.items.tools; + import java.util.EnumSet; import java.util.List; -import com.mojang.authlib.GameProfile; - import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -31,6 +30,8 @@ import net.minecraft.nbt.NBTUtil; import net.minecraft.world.World; import net.minecraftforge.client.MinecraftForgeClient; +import com.mojang.authlib.GameProfile; + import appeng.api.config.SecurityPermissions; import appeng.api.features.IPlayerRegistry; import appeng.api.implementations.items.IBiometricCard; @@ -41,26 +42,33 @@ import appeng.core.localization.GuiText; import appeng.items.AEBaseItem; import appeng.util.Platform; + public class ToolBiometricCard extends AEBaseItem implements IBiometricCard { - - public ToolBiometricCard() { - super( ToolBiometricCard.class ); + public ToolBiometricCard() + { this.setFeature( EnumSet.of( AEFeature.Security ) ); this.setMaxStackSize( 1 ); + if ( Platform.isClient() ) MinecraftForgeClient.registerItemRenderer( this, new ToolBiometricCardRender() ); } @Override - public String getItemStackDisplayName(ItemStack is) + public ItemStack onItemRightClick( ItemStack is, World w, EntityPlayer p ) { - GameProfile username = this.getProfile( is ); - return username != null ? super.getItemStackDisplayName( is ) + " - " + username.getName() : super.getItemStackDisplayName( is ); + if ( p.isSneaking() ) + { + this.encode( is, p ); + p.swingItem(); + return is; + } + + return is; } @Override - public boolean itemInteractionForEntity(ItemStack is, EntityPlayer par2EntityPlayer, EntityLivingBase target) + public boolean itemInteractionForEntity( ItemStack is, EntityPlayer par2EntityPlayer, EntityLivingBase target ) { if ( target instanceof EntityPlayer && !par2EntityPlayer.isSneaking() ) { @@ -74,66 +82,53 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard } @Override - public ItemStack onItemRightClick(ItemStack is, World w, EntityPlayer p) + public String getItemStackDisplayName( ItemStack is ) { - if ( p.isSneaking() ) - { - this.encode( is, p ); - p.swingItem(); - return is; - } - - return is; + GameProfile username = this.getProfile( is ); + return username != null ? super.getItemStackDisplayName( is ) + " - " + username.getName() : super.getItemStackDisplayName( is ); } - private void encode(ItemStack is, EntityPlayer p) + private void encode( ItemStack is, EntityPlayer p ) { GameProfile username = this.getProfile( is ); - if (username != null && username.equals(p.getGameProfile())) + if ( username != null && username.equals( p.getGameProfile() ) ) this.setProfile( is, null ); else this.setProfile( is, p.getGameProfile() ); } @Override - public void addCheckedInformation(ItemStack stack, EntityPlayer player, List lines, boolean displayAdditionalInformation ) + public void setProfile( ItemStack itemStack, GameProfile profile ) { - EnumSet perms = this.getPermissions( stack ); - if ( perms.isEmpty() ) - lines.add( GuiText.NoPermissions.getLocal() ); - else + NBTTagCompound tag = Platform.openNbtData( itemStack ); + + if ( profile != null ) { - String msg = null; - - for (SecurityPermissions sp : perms) - { - if ( msg == null ) - msg = Platform.gui_localize( sp.getUnlocalizedName() ); - else - msg = msg + ", " + Platform.gui_localize( sp.getUnlocalizedName() ); - } - lines.add( msg ); + NBTTagCompound pNBT = new NBTTagCompound(); + NBTUtil.func_152460_a( pNBT, profile ); + tag.setTag( "profile", pNBT ); } - + else + tag.removeTag( "profile" ); } @Override - public GameProfile getProfile(ItemStack is) + public GameProfile getProfile( ItemStack is ) { NBTTagCompound tag = Platform.openNbtData( is ); - if ( tag.hasKey("profile") ) - return NBTUtil.func_152459_a(tag.getCompoundTag("profile") ); + if ( tag.hasKey( "profile" ) ) + return NBTUtil.func_152459_a( tag.getCompoundTag( "profile" ) ); return null; } @Override - public EnumSet getPermissions(ItemStack is) + public EnumSet getPermissions( ItemStack is ) { NBTTagCompound tag = Platform.openNbtData( is ); EnumSet result = EnumSet.noneOf( SecurityPermissions.class ); - for (SecurityPermissions sp : SecurityPermissions.values()) + for ( SecurityPermissions sp : SecurityPermissions.values() ) { if ( tag.getBoolean( sp.name() ) ) result.add( sp ); @@ -143,29 +138,14 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard } @Override - public boolean hasPermission(ItemStack is, SecurityPermissions permission) + public boolean hasPermission( ItemStack is, SecurityPermissions permission ) { NBTTagCompound tag = Platform.openNbtData( is ); return tag.getBoolean( permission.name() ); } @Override - public void setProfile(ItemStack itemStack, GameProfile profile) - { - NBTTagCompound tag = Platform.openNbtData( itemStack ); - - if ( profile!= null ) - { - NBTTagCompound pNBT = new NBTTagCompound(); - NBTUtil.func_152460_a( pNBT, profile ); - tag.setTag( "profile", pNBT ); - } - else - tag.removeTag("profile"); - } - - @Override - public void removePermission(ItemStack itemStack, SecurityPermissions permission) + public void removePermission( ItemStack itemStack, SecurityPermissions permission ) { NBTTagCompound tag = Platform.openNbtData( itemStack ); if ( tag.hasKey( permission.name() ) ) @@ -173,15 +153,36 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard } @Override - public void addPermission(ItemStack itemStack, SecurityPermissions permission) + public void addPermission( ItemStack itemStack, SecurityPermissions permission ) { NBTTagCompound tag = Platform.openNbtData( itemStack ); tag.setBoolean( permission.name(), true ); } @Override - public void registerPermissions(ISecurityRegistry register, IPlayerRegistry pr, ItemStack is) + public void registerPermissions( ISecurityRegistry register, IPlayerRegistry pr, ItemStack is ) { register.addPlayer( pr.getID( this.getProfile( is ) ), this.getPermissions( is ) ); } + + @Override + public void addCheckedInformation( ItemStack stack, EntityPlayer player, List lines, boolean displayAdditionalInformation ) + { + EnumSet perms = this.getPermissions( stack ); + if ( perms.isEmpty() ) + lines.add( GuiText.NoPermissions.getLocal() ); + else + { + String msg = null; + + for ( SecurityPermissions sp : perms ) + { + if ( msg == null ) + msg = Platform.gui_localize( sp.getUnlocalizedName() ); + else + msg = msg + ", " + Platform.gui_localize( sp.getUnlocalizedName() ); + } + lines.add( msg ); + } + } } diff --git a/src/main/java/appeng/items/tools/ToolMemoryCard.java b/src/main/java/appeng/items/tools/ToolMemoryCard.java index f68aec210..14a7b5fd7 100644 --- a/src/main/java/appeng/items/tools/ToolMemoryCard.java +++ b/src/main/java/appeng/items/tools/ToolMemoryCard.java @@ -36,38 +36,17 @@ import appeng.core.localization.PlayerMessages; import appeng.items.AEBaseItem; import appeng.util.Platform; + public class ToolMemoryCard extends AEBaseItem implements IMemoryCard { - - public ToolMemoryCard() { - super( ToolMemoryCard.class ); + public ToolMemoryCard() + { this.setFeature( EnumSet.of( AEFeature.Core ) ); this.setMaxStackSize( 1 ); } - /** - * Find the localized string... - * - * @param name possible names for the localized string - * @return localized name - */ - private String getLocalizedName(String... name) - { - for (String n : name) - { - String l = StatCollector.translateToLocal( n ); - if ( !l.equals( n ) ) - return l; - } - - for (String n : name) - return n; - - return ""; - } - @Override - public void addCheckedInformation(ItemStack stack, EntityPlayer player, List lines, boolean displayAdditionalInformation ) + public void addCheckedInformation( ItemStack stack, EntityPlayer player, List lines, boolean displayAdditionalInformation ) { lines.add( this.getLocalizedName( this.getSettingsName( stack ) + ".name", this.getSettingsName( stack ) ) ); @@ -76,22 +55,38 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard lines.add( StatCollector.translateToLocal( this.getLocalizedName( data.getString( "tooltip" ) + ".name", data.getString( "tooltip" ) ) ) ); } - @Override - public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) + /** + * Find the localized string... + * + * @param name possible names for the localized string + * + * @return localized name + */ + private String getLocalizedName( String... name ) { - return true; + for ( String n : name ) + { + String l = StatCollector.translateToLocal( n ); + if ( !l.equals( n ) ) + return l; + } + + for ( String n : name ) + return n; + + return ""; } @Override - public void setMemoryCardContents(ItemStack is, String SettingsName, NBTTagCompound data) + public void setMemoryCardContents( ItemStack is, String settingsName, NBTTagCompound data ) { NBTTagCompound c = Platform.openNbtData( is ); - c.setString( "Config", SettingsName ); + c.setString( "Config", settingsName ); c.setTag( "Data", data ); } @Override - public String getSettingsName(ItemStack is) + public String getSettingsName( ItemStack is ) { NBTTagCompound c = Platform.openNbtData( is ); String name = c.getString( "Config" ); @@ -99,7 +94,7 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard } @Override - public NBTTagCompound getData(ItemStack is) + public NBTTagCompound getData( ItemStack is ) { NBTTagCompound c = Platform.openNbtData( is ); NBTTagCompound o = c.getCompoundTag( "Data" ); @@ -109,7 +104,31 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard } @Override - public boolean onItemUse(ItemStack is, EntityPlayer player, World w, int x, int y, int z, int side, float hx, float hy, float hz) + public void notifyUser( EntityPlayer player, MemoryCardMessages msg ) + { + if ( Platform.isClient() ) + return; + + switch ( msg ) + { + case SETTINGS_CLEARED: + player.addChatMessage( PlayerMessages.SettingCleared.get() ); + break; + case INVALID_MACHINE: + player.addChatMessage( PlayerMessages.InvalidMachine.get() ); + break; + case SETTINGS_LOADED: + player.addChatMessage( PlayerMessages.LoadedSettings.get() ); + break; + case SETTINGS_SAVED: + player.addChatMessage( PlayerMessages.SavedSettings.get() ); + break; + default: + } + } + + @Override + public boolean onItemUse( ItemStack is, EntityPlayer player, World w, int x, int y, int z, int side, float hx, float hy, float hz ) { if ( player.isSneaking() && !w.isRemote ) { @@ -123,27 +142,8 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard } @Override - public void notifyUser(EntityPlayer player, MemoryCardMessages msg) + public boolean doesSneakBypassUse( World world, int x, int y, int z, EntityPlayer player ) { - if ( Platform.isClient() ) - return; - - switch (msg) - { - case SETTINGS_CLEARED: - player.addChatMessage( PlayerMessages.SettingCleared.get() ); - break; - case INVALID_MACHINE: - player.addChatMessage( PlayerMessages.InvalidMachine.get() ); - break; - case SETTINGS_LOADED: - player.addChatMessage( PlayerMessages.LoadedSettings.get() ); - break; - case SETTINGS_SAVED: - player.addChatMessage( PlayerMessages.SavedSettings.get() ); - break; - default: - } + return true; } - } diff --git a/src/main/java/appeng/items/tools/ToolNetworkTool.java b/src/main/java/appeng/items/tools/ToolNetworkTool.java index c31876f36..d4cdb7338 100644 --- a/src/main/java/appeng/items/tools/ToolNetworkTool.java +++ b/src/main/java/appeng/items/tools/ToolNetworkTool.java @@ -21,8 +21,6 @@ package appeng.items.tools; import java.util.EnumSet; -import com.google.common.base.Optional; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -33,6 +31,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.tools.IToolWrench; +import com.google.common.base.Optional; import appeng.api.implementations.guiobjects.IGuiItem; import appeng.api.implementations.guiobjects.IGuiItemObject; @@ -60,7 +59,7 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench, public ToolNetworkTool() { - super( ToolNetworkTool.class, Optional. absent() ); + super( Optional. absent() ); this.setFeature( EnumSet.of( AEFeature.NetworkTool ) ); this.setMaxStackSize( 1 ); diff --git a/src/main/java/appeng/items/tools/powered/ToolChargedStaff.java b/src/main/java/appeng/items/tools/powered/ToolChargedStaff.java index 1ab5c8185..caf8a53be 100644 --- a/src/main/java/appeng/items/tools/powered/ToolChargedStaff.java +++ b/src/main/java/appeng/items/tools/powered/ToolChargedStaff.java @@ -21,12 +21,12 @@ package appeng.items.tools.powered; import java.util.EnumSet; -import com.google.common.base.Optional; - import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; +import com.google.common.base.Optional; + import appeng.core.AEConfig; import appeng.core.features.AEFeature; import appeng.core.sync.packets.PacketLightning; @@ -40,9 +40,8 @@ public class ToolChargedStaff extends AEBasePoweredItem public ToolChargedStaff() { - super( ToolChargedStaff.class, Optional. absent() ); + super( AEConfig.instance.chargedStaffBattery, Optional. absent() ); this.setFeature( EnumSet.of( AEFeature.ChargedStaff, AEFeature.PoweredTools ) ); - this.maxStoredPower = AEConfig.instance.chargedStaffBattery; } @Override diff --git a/src/main/java/appeng/items/tools/powered/ToolColorApplicator.java b/src/main/java/appeng/items/tools/powered/ToolColorApplicator.java index 473722fd6..1af889d25 100644 --- a/src/main/java/appeng/items/tools/powered/ToolColorApplicator.java +++ b/src/main/java/appeng/items/tools/powered/ToolColorApplicator.java @@ -28,8 +28,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import com.google.common.base.Optional; - import net.minecraft.block.Block; import net.minecraft.block.BlockDispenser; import net.minecraft.entity.player.EntityPlayer; @@ -44,6 +42,8 @@ import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.OreDictionary; +import com.google.common.base.Optional; + import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.config.FuzzyMode; @@ -99,9 +99,8 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe public ToolColorApplicator() { - super( ToolColorApplicator.class, Optional. absent() ); + super( AEConfig.instance.colorApplicatorBattery, Optional. absent() ); this.setFeature( EnumSet.of( AEFeature.ColorApplicator, AEFeature.PoweredTools ) ); - this.maxStoredPower = AEConfig.instance.colorApplicatorBattery; if ( Platform.isClient() ) MinecraftForgeClient.registerItemRenderer( this, new ToolColorApplicatorRender() ); } diff --git a/src/main/java/appeng/items/tools/powered/ToolEntropyManipulator.java b/src/main/java/appeng/items/tools/powered/ToolEntropyManipulator.java index ff22c3851..0c76d7b8d 100644 --- a/src/main/java/appeng/items/tools/powered/ToolEntropyManipulator.java +++ b/src/main/java/appeng/items/tools/powered/ToolEntropyManipulator.java @@ -62,15 +62,13 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT public ToolEntropyManipulator() { - super( ToolEntropyManipulator.class, Optional.absent() ); + super( AEConfig.instance.entropyManipulatorBattery, Optional.absent() ); this.setFeature( EnumSet.of( AEFeature.EntropyManipulator, AEFeature.PoweredTools ) ); this.heatUp = new HashMap(); this.coolDown = new HashMap(); - this.maxStoredPower = AEConfig.instance.entropyManipulatorBattery; - this.coolDown.put( new InWorldToolOperationIngredient( Blocks.stone, 0 ), new InWorldToolOperationResult( new ItemStack( Blocks.cobblestone ) ) ); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.stonebrick, 0 ), new InWorldToolOperationResult( new ItemStack( Blocks.stonebrick, 1, 2 ) ) ); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.lava, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult( new ItemStack( Blocks.obsidian ) ) ); diff --git a/src/main/java/appeng/items/tools/powered/ToolMassCannon.java b/src/main/java/appeng/items/tools/powered/ToolMassCannon.java index a450f3063..b337c3dbb 100644 --- a/src/main/java/appeng/items/tools/powered/ToolMassCannon.java +++ b/src/main/java/appeng/items/tools/powered/ToolMassCannon.java @@ -22,8 +22,6 @@ package appeng.items.tools.powered; import java.util.EnumSet; import java.util.List; -import com.google.common.base.Optional; - import net.minecraft.block.Block; import net.minecraft.block.BlockDispenser; import net.minecraft.entity.Entity; @@ -43,6 +41,8 @@ import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import com.google.common.base.Optional; + import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.config.FuzzyMode; @@ -83,9 +83,8 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell public ToolMassCannon() { - super( ToolMassCannon.class, Optional. absent() ); + super( AEConfig.instance.matterCannonBattery, Optional. absent() ); this.setFeature( EnumSet.of( AEFeature.MatterCannon, AEFeature.PoweredTools ) ); - this.maxStoredPower = AEConfig.instance.matterCannonBattery; } @Override @@ -297,7 +296,10 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell Block whatsThere = w.getBlock( x, y, z ); if ( whatsThere.isReplaceable( w, x, y, z ) && w.isAirBlock( x, y, z ) ) { - w.setBlock( x, y, z, AEApi.instance().blocks().blockPaint.block(), 0, 3 ); + for ( Block paintBlock : AEApi.instance().definitions().blocks().paint().maybeBlock().asSet() ) + { + w.setBlock( x, y, z, paintBlock, 0, 3 ); + } } TileEntity te = w.getTileEntity( x, y, z ); diff --git a/src/main/java/appeng/items/tools/powered/ToolPortableCell.java b/src/main/java/appeng/items/tools/powered/ToolPortableCell.java index 36e76d44c..5fd4ec728 100644 --- a/src/main/java/appeng/items/tools/powered/ToolPortableCell.java +++ b/src/main/java/appeng/items/tools/powered/ToolPortableCell.java @@ -23,8 +23,6 @@ import java.util.EnumSet; import java.util.List; import java.util.Set; -import com.google.common.base.Optional; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -34,6 +32,8 @@ import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import com.google.common.base.Optional; + import appeng.api.AEApi; import appeng.api.config.FuzzyMode; import appeng.api.implementations.guiobjects.IGuiItem; @@ -61,9 +61,8 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell, { public ToolPortableCell() { - super( ToolPortableCell.class, Optional. absent() ); + super( AEConfig.instance.portableCellBattery, Optional. absent() ); this.setFeature( EnumSet.of( AEFeature.PortableCell, AEFeature.StorageCells, AEFeature.PoweredTools ) ); - this.maxStoredPower = AEConfig.instance.portableCellBattery; } @SideOnly(Side.CLIENT) diff --git a/src/main/java/appeng/items/tools/powered/ToolWirelessTerminal.java b/src/main/java/appeng/items/tools/powered/ToolWirelessTerminal.java index f5f0188d4..9bd518a90 100644 --- a/src/main/java/appeng/items/tools/powered/ToolWirelessTerminal.java +++ b/src/main/java/appeng/items/tools/powered/ToolWirelessTerminal.java @@ -22,8 +22,6 @@ package appeng.items.tools.powered; import java.util.EnumSet; import java.util.List; -import com.google.common.base.Optional; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -33,6 +31,8 @@ import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import com.google.common.base.Optional; + import appeng.api.AEApi; import appeng.api.config.Settings; import appeng.api.config.SortDir; @@ -54,9 +54,8 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless public ToolWirelessTerminal() { - super( ToolWirelessTerminal.class, Optional. absent() ); + super( AEConfig.instance.wirelessTerminalBattery, Optional. absent() ); this.setFeature( EnumSet.of( AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools ) ); - this.maxStoredPower = AEConfig.instance.wirelessTerminalBattery; } @SideOnly(Side.CLIENT) @@ -98,7 +97,7 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless @Override public boolean canHandle( ItemStack is ) { - return AEApi.instance().items().itemWirelessTerminal.sameAsStack( is ); + return AEApi.instance().definitions().items().wirelessTerminal().isSameAs( is ); } @Override diff --git a/src/main/java/appeng/items/tools/powered/powersink/AEBasePoweredItem.java b/src/main/java/appeng/items/tools/powered/powersink/AEBasePoweredItem.java index b990b4f91..4d05d132c 100644 --- a/src/main/java/appeng/items/tools/powered/powersink/AEBasePoweredItem.java +++ b/src/main/java/appeng/items/tools/powered/powersink/AEBasePoweredItem.java @@ -22,12 +22,11 @@ package appeng.items.tools.powered.powersink; import com.google.common.base.Optional; -public class AEBasePoweredItem extends RedstoneFlux +public abstract class AEBasePoweredItem extends RedstoneFlux { - - public AEBasePoweredItem( Class c, Optional subName ) + public AEBasePoweredItem( double powerCapacity, Optional subName ) { - super( c, subName ); + super( powerCapacity, subName ); this.setMaxStackSize( 1 ); } diff --git a/src/main/java/appeng/items/tools/powered/powersink/AERootPoweredItem.java b/src/main/java/appeng/items/tools/powered/powersink/AERootPoweredItem.java index 65b622b2c..be49139e7 100644 --- a/src/main/java/appeng/items/tools/powered/powersink/AERootPoweredItem.java +++ b/src/main/java/appeng/items/tools/powered/powersink/AERootPoweredItem.java @@ -22,14 +22,14 @@ package appeng.items.tools.powered.powersink; import java.text.MessageFormat; import java.util.List; -import com.google.common.base.Optional; - import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import com.google.common.base.Optional; + import appeng.api.config.AccessRestriction; import appeng.api.config.PowerUnits; import appeng.api.implementations.items.IAEItemPowerStorage; @@ -38,18 +38,19 @@ import appeng.items.AEBaseItem; import appeng.util.Platform; -public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage +public abstract class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage { + private static final String POWER_NBT_KEY = "internalCurrentPower"; + private final double powerCapacity; - final String EnergyVar = "internalCurrentPower"; - public double maxStoredPower = 200000; - - public AERootPoweredItem( Class c, Optional subName ) + public AERootPoweredItem( double powerCapacity, Optional subName ) { - super( c, subName ); + super( subName ); this.setMaxDamage( 32 ); this.hasSubtypes = false; this.setFull3D(); + + this.powerCapacity = powerCapacity; } @Override @@ -148,7 +149,7 @@ public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage { NBTTagCompound data = Platform.openNbtData( is ); - double currentStorage = data.getDouble( this.EnergyVar ); + double currentStorage = data.getDouble( this.POWER_NBT_KEY ); double maxStorage = this.getAEMaxPower( is ); switch ( op ) @@ -158,19 +159,19 @@ public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage if ( currentStorage > maxStorage ) { double diff = currentStorage - maxStorage; - data.setDouble( this.EnergyVar, maxStorage ); + data.setDouble( this.POWER_NBT_KEY, maxStorage ); return diff; } - data.setDouble( this.EnergyVar, currentStorage ); + data.setDouble( this.POWER_NBT_KEY, currentStorage ); return 0; case EXTRACT: if ( currentStorage > adjustment ) { currentStorage -= adjustment; - data.setDouble( this.EnergyVar, currentStorage ); + data.setDouble( this.POWER_NBT_KEY, currentStorage ); return adjustment; } - data.setDouble( this.EnergyVar, 0 ); + data.setDouble( this.POWER_NBT_KEY, 0 ); return currentStorage; default: break; @@ -182,7 +183,7 @@ public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage @Override public double getAEMaxPower( ItemStack is ) { - return this.maxStoredPower; + return this.powerCapacity; } @Override diff --git a/src/main/java/appeng/items/tools/powered/powersink/IC2.java b/src/main/java/appeng/items/tools/powered/powersink/IC2.java index 7e7a80b38..5d9033356 100644 --- a/src/main/java/appeng/items/tools/powered/powersink/IC2.java +++ b/src/main/java/appeng/items/tools/powered/powersink/IC2.java @@ -19,12 +19,11 @@ package appeng.items.tools.powered.powersink; -import com.google.common.base.Optional; - import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import com.google.common.base.Optional; import ic2.api.item.IElectricItemManager; import ic2.api.item.ISpecialElectricItem; @@ -36,12 +35,11 @@ import appeng.transformer.annotations.Integration.Method; @InterfaceList( value = { @Interface( iface = "ic2.api.item.ISpecialElectricItem", iname = "IC2" ), @Interface( iface = "ic2.api.item.IElectricItemManager", iname = "IC2" ) } ) -public class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpecialElectricItem +public abstract class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpecialElectricItem { - - public IC2( Class c, Optional subName ) + public IC2( double powerCapacity, Optional subName ) { - super( c, subName ); + super( powerCapacity, subName ); } @Override diff --git a/src/main/java/appeng/items/tools/powered/powersink/RedstoneFlux.java b/src/main/java/appeng/items/tools/powered/powersink/RedstoneFlux.java index 9f1d2b1a5..a48c2c6ac 100644 --- a/src/main/java/appeng/items/tools/powered/powersink/RedstoneFlux.java +++ b/src/main/java/appeng/items/tools/powered/powersink/RedstoneFlux.java @@ -19,29 +19,27 @@ package appeng.items.tools.powered.powersink; -import com.google.common.base.Optional; - import net.minecraft.item.ItemStack; import cofh.api.energy.IEnergyContainerItem; +import com.google.common.base.Optional; import appeng.api.config.PowerUnits; import appeng.transformer.annotations.Integration.Interface; @Interface( iface = "cofh.api.energy.IEnergyContainerItem", iname = "RFItem" ) -public class RedstoneFlux extends IC2 implements IEnergyContainerItem +public abstract class RedstoneFlux extends IC2 implements IEnergyContainerItem { - - public RedstoneFlux( Class c, Optional subName ) + public RedstoneFlux( double powerCapacity, Optional subName ) { - super( c, subName ); + super( powerCapacity, subName ); } @Override public int receiveEnergy( ItemStack is, int maxReceive, boolean simulate ) { - return maxReceive - ( int ) this.injectExternalPower( PowerUnits.RF, is, maxReceive, simulate ); + return maxReceive - (int) this.injectExternalPower( PowerUnits.RF, is, maxReceive, simulate ); } @Override @@ -53,13 +51,12 @@ public class RedstoneFlux extends IC2 implements IEnergyContainerItem @Override public int getEnergyStored( ItemStack is ) { - return ( int ) PowerUnits.AE.convertTo( PowerUnits.RF, this.getAECurrentPower( is ) ); + return (int) PowerUnits.AE.convertTo( PowerUnits.RF, this.getAECurrentPower( is ) ); } @Override public int getMaxEnergyStored( ItemStack is ) { - return ( int ) PowerUnits.AE.convertTo( PowerUnits.RF, this.getAEMaxPower( is ) ); + return (int) PowerUnits.AE.convertTo( PowerUnits.RF, this.getAEMaxPower( is ) ); } - } diff --git a/src/main/java/appeng/items/tools/quartz/ToolQuartzCuttingKnife.java b/src/main/java/appeng/items/tools/quartz/ToolQuartzCuttingKnife.java index e5f13f109..9f74758f2 100644 --- a/src/main/java/appeng/items/tools/quartz/ToolQuartzCuttingKnife.java +++ b/src/main/java/appeng/items/tools/quartz/ToolQuartzCuttingKnife.java @@ -21,13 +21,13 @@ package appeng.items.tools.quartz; import java.util.EnumSet; -import com.google.common.base.Optional; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import com.google.common.base.Optional; + import appeng.api.implementations.guiobjects.IGuiItem; import appeng.api.implementations.guiobjects.IGuiItemObject; import appeng.core.features.AEFeature; @@ -39,14 +39,14 @@ import appeng.util.Platform; public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem { + private final AEFeature type; - final AEFeature type; - - public ToolQuartzCuttingKnife( AEFeature Type ) + public ToolQuartzCuttingKnife( AEFeature type ) { - super( ToolQuartzCuttingKnife.class, Optional.of( Type.name() ) ); + super( Optional.of( type.name() ) ); - this.setFeature( EnumSet.of( this.type = Type, AEFeature.QuartzKnife ) ); + this.type = type; + this.setFeature( EnumSet.of( type, AEFeature.QuartzKnife ) ); this.setMaxDamage( 50 ); this.setMaxStackSize( 1 ); } diff --git a/src/main/java/appeng/items/tools/quartz/ToolQuartzWrench.java b/src/main/java/appeng/items/tools/quartz/ToolQuartzWrench.java index 7f45b40ea..084a6ffa7 100644 --- a/src/main/java/appeng/items/tools/quartz/ToolQuartzWrench.java +++ b/src/main/java/appeng/items/tools/quartz/ToolQuartzWrench.java @@ -21,8 +21,6 @@ package appeng.items.tools.quartz; import java.util.EnumSet; -import com.google.common.base.Optional; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -30,6 +28,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.tools.IToolWrench; +import com.google.common.base.Optional; import appeng.api.implementations.items.IAEWrench; import appeng.api.util.DimensionalCoord; @@ -45,7 +44,7 @@ public class ToolQuartzWrench extends AEBaseItem implements IAEWrench, IToolWren public ToolQuartzWrench( AEFeature type ) { - super( ToolQuartzWrench.class, Optional.of( type.name() ) ); + super( Optional.of( type.name() ) ); this.setFeature( EnumSet.of( type, AEFeature.QuartzWrench ) ); this.setMaxStackSize( 1 ); diff --git a/src/main/java/appeng/me/cluster/implementations/QuantumCalculator.java b/src/main/java/appeng/me/cluster/implementations/QuantumCalculator.java index cd6cdc284..cffe3cbb8 100644 --- a/src/main/java/appeng/me/cluster/implementations/QuantumCalculator.java +++ b/src/main/java/appeng/me/cluster/implementations/QuantumCalculator.java @@ -18,16 +18,19 @@ package appeng.me.cluster.implementations; +import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import appeng.api.AEApi; +import appeng.api.definitions.IBlockDefinition; +import appeng.api.definitions.IBlocks; import appeng.api.util.WorldCoord; import appeng.me.cluster.IAECluster; import appeng.me.cluster.IAEMultiBlock; import appeng.me.cluster.MBCalculator; import appeng.tile.qnb.TileQuantumBridge; -import appeng.util.Platform; public class QuantumCalculator extends MBCalculator { @@ -75,7 +78,7 @@ public class QuantumCalculator extends MBCalculator { TileQuantumBridge te = (TileQuantumBridge) w.getTileEntity( x, y, z ); - byte flags = 0; + byte flags; num++; if ( num == 5 ) @@ -130,21 +133,34 @@ public class QuantumCalculator extends MBCalculator return false; num++; + final IBlocks blocks = AEApi.instance().definitions().blocks(); if ( num == 5 ) { - if ( !Platform.blockAtLocationIs( w, x, y, z, AEApi.instance().blocks().blockQuantumLink ) ) + if ( !this.isBlockAtLocation( w, x, y, z, blocks.quantumLink() ) ) + { return false; + } } else { - if ( !Platform.blockAtLocationIs( w, x, y, z, AEApi.instance().blocks().blockQuantumRing ) ) + if ( !this.isBlockAtLocation( w, x, y, z, blocks.quantumRing() ) ) + { return false; + } } - } } } return true; } + private boolean isBlockAtLocation( IBlockAccess w, int x, int y, int z, IBlockDefinition def ) + { + for ( Block block : def.maybeBlock().asSet() ) + { + return block == w.getBlock( x, y, z ); + } + + return false; + } } diff --git a/src/main/java/appeng/me/storage/SecurityInventory.java b/src/main/java/appeng/me/storage/SecurityInventory.java index 068065ec8..2357ff36d 100644 --- a/src/main/java/appeng/me/storage/SecurityInventory.java +++ b/src/main/java/appeng/me/storage/SecurityInventory.java @@ -63,16 +63,19 @@ public class SecurityInventory implements IMEInventoryHandler @Override public IAEItemStack injectItems(IAEItemStack input, Actionable type, BaseActionSource src) { - if ( this.hasPermission( src ) && AEApi.instance().items().itemBiometricCard.sameAsStack( input.getItemStack() ) ) + if ( this.hasPermission( src ) ) { - if ( this.canAccept( input ) ) + if ( AEApi.instance().definitions().items().biometricCard().isSameAs( input.getItemStack() ) ) { - if ( type == Actionable.SIMULATE ) - return null; + if ( this.canAccept( input ) ) + { + if ( type == Actionable.SIMULATE ) + return null; - this.storedItems.add( input ); - this.securityTile.inventoryChanged(); - return null; + this.storedItems.add( input ); + this.securityTile.inventoryChanged(); + return null; + } } } return input; diff --git a/src/main/java/appeng/parts/AEBasePart.java b/src/main/java/appeng/parts/AEBasePart.java index 95105ed2f..72d927eec 100644 --- a/src/main/java/appeng/parts/AEBasePart.java +++ b/src/main/java/appeng/parts/AEBasePart.java @@ -45,6 +45,7 @@ import cpw.mods.fml.relauncher.SideOnly; import appeng.api.AEApi; import appeng.api.config.Upgrades; +import appeng.api.definitions.IDefinitions; import appeng.api.implementations.IUpgradeableHost; import appeng.api.implementations.items.IMemoryCard; import appeng.api.implementations.items.MemoryCardMessages; @@ -70,7 +71,7 @@ import appeng.tile.inventory.AppEngInternalAEInventory; import appeng.util.Platform; import appeng.util.SettingsFrom; -public class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradeableHost, ICustomNameObject +public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradeableHost, ICustomNameObject { protected ISimplifiedBundle renderCache = null; @@ -82,7 +83,7 @@ public class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradea protected final ItemStack is; - public AEBasePart(Class c, ItemStack is) { + public AEBasePart(ItemStack is) { this.is = is; this.proxy = new AENetworkProxy( this, "part", is, this instanceof PartCable ); this.proxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) ); @@ -386,8 +387,14 @@ public class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradea ItemStack is = this.getItemStack( PartItemStack.Network ); // Blocks and parts share the same soul! - if ( AEApi.instance().parts().partInterface.sameAsStack( is ) ) - is = AEApi.instance().blocks().blockInterface.stack( 1 ); + final IDefinitions definitions = AEApi.instance().definitions(); + if ( definitions.parts().iface().isSameAs( is ) ) + { + for ( ItemStack iface : definitions.blocks().iface().maybeStack( 1 ).asSet() ) + { + is = iface; + } + } String name = is.getUnlocalizedName(); diff --git a/src/main/java/appeng/parts/PartBasicState.java b/src/main/java/appeng/parts/PartBasicState.java index 3e0d53e10..7e1344380 100644 --- a/src/main/java/appeng/parts/PartBasicState.java +++ b/src/main/java/appeng/parts/PartBasicState.java @@ -18,6 +18,7 @@ package appeng.parts; + import java.io.IOException; import io.netty.buffer.ByteBuf; @@ -40,7 +41,8 @@ import appeng.api.parts.IPartRenderHelper; import appeng.client.texture.CableBusTextures; import appeng.me.GridAccessException; -public class PartBasicState extends AEBasePart implements IPowerChannelState + +public abstract class PartBasicState extends AEBasePart implements IPowerChannelState { protected final int POWERED_FLAG = 1; @@ -48,19 +50,36 @@ public class PartBasicState extends AEBasePart implements IPowerChannelState protected int clientFlags = 0; // sent as byte. + public PartBasicState( ItemStack is ) + { + super( is ); + this.proxy.setFlags( GridFlags.REQUIRE_CHANNEL ); + } + @MENetworkEventSubscribe - public void chanRender(MENetworkChannelsChanged c) + public void chanRender( MENetworkChannelsChanged c ) { this.getHost().markForUpdate(); } @MENetworkEventSubscribe - public void powerRender(MENetworkPowerStatusChange c) + public void powerRender( MENetworkPowerStatusChange c ) { this.getHost().markForUpdate(); } - public void setColors(boolean hasChan, boolean hasPower) + @SideOnly( Side.CLIENT ) + public void renderLights( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ) + { + rh.normalRendering(); + this.setColors( ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) == ( this.POWERED_FLAG | this.CHANNEL_FLAG ), ( this.clientFlags & this.POWERED_FLAG ) == this.POWERED_FLAG ); + rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.EAST, renderer ); + rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.WEST, renderer ); + rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.UP, renderer ); + rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.DOWN, renderer ); + } + + public void setColors( boolean hasChan, boolean hasPower ) { if ( hasChan ) { @@ -81,19 +100,8 @@ public class PartBasicState extends AEBasePart implements IPowerChannelState } } - @SideOnly(Side.CLIENT) - public void renderLights(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer) - { - rh.normalRendering(); - this.setColors( (this.clientFlags & (this.POWERED_FLAG | this.CHANNEL_FLAG)) == (this.POWERED_FLAG | this.CHANNEL_FLAG), (this.clientFlags & this.POWERED_FLAG) == this.POWERED_FLAG ); - rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.EAST, renderer ); - rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.WEST, renderer ); - rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.UP, renderer ); - rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.DOWN, renderer ); - } - @Override - public void writeToStream(ByteBuf data) throws IOException + public void writeToStream( ByteBuf data ) throws IOException { super.writeToStream( data ); @@ -109,7 +117,7 @@ public class PartBasicState extends AEBasePart implements IPowerChannelState this.clientFlags = this.populateFlags( this.clientFlags ); } - catch (GridAccessException e) + catch ( GridAccessException e ) { // meh } @@ -117,13 +125,13 @@ public class PartBasicState extends AEBasePart implements IPowerChannelState data.writeByte( (byte) this.clientFlags ); } - protected int populateFlags(int cf) + protected int populateFlags( int cf ) { return cf; } @Override - public boolean readFromStream(ByteBuf data) throws IOException + public boolean readFromStream( ByteBuf data ) throws IOException { boolean eh = super.readFromStream( data ); @@ -133,27 +141,22 @@ public class PartBasicState extends AEBasePart implements IPowerChannelState return eh || old != this.clientFlags; } - public PartBasicState(Class c, ItemStack is) { - super( c, is ); - this.proxy.setFlags( GridFlags.REQUIRE_CHANNEL ); + @Override + @SideOnly( Side.CLIENT ) + public IIcon getBreakingTexture() + { + return CableBusTextures.PartTransitionPlaneBack.getIcon(); } @Override public boolean isPowered() { - return (this.clientFlags & this.POWERED_FLAG) == this.POWERED_FLAG; + return ( this.clientFlags & this.POWERED_FLAG ) == this.POWERED_FLAG; } @Override public boolean isActive() { - return (this.clientFlags & this.CHANNEL_FLAG) == this.CHANNEL_FLAG; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getBreakingTexture() - { - return CableBusTextures.PartTransitionPlaneBack.getIcon(); + return ( this.clientFlags & this.CHANNEL_FLAG ) == this.CHANNEL_FLAG; } } diff --git a/src/main/java/appeng/parts/PartPlacement.java b/src/main/java/appeng/parts/PartPlacement.java index 279849b36..1fcadb607 100644 --- a/src/main/java/appeng/parts/PartPlacement.java +++ b/src/main/java/appeng/parts/PartPlacement.java @@ -18,6 +18,7 @@ package appeng.parts; + import java.util.LinkedList; import java.util.List; @@ -40,8 +41,11 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; +import com.google.common.base.Optional; + import appeng.api.AEApi; -import appeng.api.definitions.Items; +import appeng.api.definitions.IBlockDefinition; +import appeng.api.definitions.IItems; import appeng.api.parts.IFacadePart; import appeng.api.parts.IPartHost; import appeng.api.parts.IPartItem; @@ -61,78 +65,15 @@ import appeng.integration.abstraction.IImmibisMicroblocks; import appeng.util.LookDirection; import appeng.util.Platform; + public class PartPlacement { + public static float eyeHeight = 0.0f; private final ThreadLocal placing = new ThreadLocal(); private boolean wasCanceled = false; - @SubscribeEvent - public void playerInteract(TickEvent.ClientTickEvent event) - { - this.wasCanceled = false; - } - - @SubscribeEvent - public void playerInteract(PlayerInteractEvent event) - { - if ( event.action == Action.RIGHT_CLICK_AIR && event.entityPlayer.worldObj.isRemote ) - { - // re-check to see if this event was already channeled, cause these two events are really stupid... - MovingObjectPosition mop = Platform.rayTrace( event.entityPlayer, true, false ); - Minecraft mc = Minecraft.getMinecraft(); - - float f = 1.0F; - double d0 = mc.playerController.getBlockReachDistance(); - Vec3 vec3 = mc.renderViewEntity.getPosition( f ); - - if ( mop != null && mop.hitVec.distanceTo( vec3 ) < d0 ) - { - World w = event.entity.worldObj; - TileEntity te = w.getTileEntity( mop.blockX, mop.blockY, mop.blockZ ); - if ( te instanceof IPartHost && this.wasCanceled ) - event.setCanceled( true ); - } - else - { - ItemStack held = event.entityPlayer.getHeldItem(); - final Items items = AEApi.instance().items(); - - final boolean sameAsMemoryCard = items.itemMemoryCard != null && items.itemMemoryCard.sameAsStack( held ); - final boolean sameAsColorApp = items.itemColorApplicator != null && items.itemColorApplicator.sameAsStack( held ); - - final boolean supportedItem = sameAsMemoryCard || sameAsColorApp; - - if ( event.entityPlayer.isSneaking() && held != null && supportedItem ) - { - NetworkHandler.instance.sendToServer( new PacketClick( event.x, event.y, event.z, event.face, 0, 0, 0 ) ); - } - } - } - else if ( event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote ) - { - if ( this.placing.get() != null ) - return; - - this.placing.set( event ); - - ItemStack held = event.entityPlayer.getHeldItem(); - if ( place( held, event.x, event.y, event.z, event.face, event.entityPlayer, event.entityPlayer.worldObj, PlaceType.INTERACT_FIRST_PASS, 0 ) ) - { - event.setCanceled( true ); - this.wasCanceled = true; - } - - this.placing.set( null ); - } - } - - public enum PlaceType - { - PLACE_ITEM, INTERACT_FIRST_PASS, INTERACT_SECOND_PASS - } - - public static boolean place(ItemStack held, int x, int y, int z, int face, EntityPlayer player, World world, PlaceType pass, int depth) + public static boolean place( ItemStack held, int x, int y, int z, int face, EntityPlayer player, World world, PlaceType pass, int depth ) { if ( depth > 3 ) return false; @@ -244,10 +185,10 @@ public class PartPlacement } if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) ) - host = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getOrCreateHost( tile ); + host = ( (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP ) ).getOrCreateHost( tile ); if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) ) - host = ((IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks )).getOrCreateHost( player, face, tile ); + host = ( (IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks ) ).getOrCreateHost( player, face, tile ); // if ( held == null ) { @@ -271,20 +212,18 @@ public class PartPlacement } } } - } - if ( held == null || !(held.getItem() instanceof IPartItem) ) + if ( held == null || !( held.getItem() instanceof IPartItem ) ) return false; int te_x = x; int te_y = y; int te_z = z; + final IBlockDefinition multiPart = AEApi.instance().definitions().blocks().multiPart(); if ( host == null && pass == PlaceType.PLACE_ITEM ) { - ItemStack is = AEApi.instance().blocks().blockMultiPart.stack( 1 ); - ItemBlock ib = (ItemBlock) is.getItem(); ForgeDirection offset = ForgeDirection.UNKNOWN; Block blkID = world.getBlock( x, y, z ); @@ -304,13 +243,20 @@ public class PartPlacement host = (IPartHost) tile; if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) ) - host = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getOrCreateHost( tile ); + host = ( (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP ) ).getOrCreateHost( tile ); if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) ) - host = ((IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks )).getOrCreateHost( player, face, tile ); + host = ( (IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks ) ).getOrCreateHost( player, face, tile ); - if ( host == null && AEApi.instance().blocks().blockMultiPart.block().canPlaceBlockAt( world, te_x, te_y, te_z ) - && ib.placeBlockAt( is, player, world, te_x, te_y, te_z, side.ordinal(), 0.5f, 0.5f, 0.5f, 0 ) ) + final Optional maybeMultiPartStack = multiPart.maybeStack( 1 ); + final Optional maybeMultiPartBlock = multiPart.maybeBlock(); + final Optional maybeMultiPartItemBlock = multiPart.maybeItemBlock(); + + final boolean hostIsNotPresent = host == null; + final boolean multiPartPresent = maybeMultiPartBlock.isPresent() && maybeMultiPartStack.isPresent() && maybeMultiPartItemBlock.isPresent(); + final boolean canMultiPartBePlaced = maybeMultiPartBlock.get().canPlaceBlockAt( world, te_x, te_y, te_z ); + + if ( hostIsNotPresent && multiPartPresent && canMultiPartBePlaced && maybeMultiPartItemBlock.get().placeBlockAt( maybeMultiPartStack.get(), player, world, te_x, te_y, te_z, side.ordinal(), 0.5f, 0.5f, 0.5f, 0 ) ) { if ( !world.isRemote ) { @@ -329,7 +275,9 @@ public class PartPlacement } } else if ( host != null && !host.canAddPart( held, side ) ) + { return false; + } } if ( host == null ) @@ -347,11 +295,10 @@ public class PartPlacement tile = world.getTileEntity( te_x, te_y, te_z ); if ( tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) ) - host = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getOrCreateHost( tile ); + host = ( (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP ) ).getOrCreateHost( tile ); - if ( (blkID == null || blkID.isReplaceable( world, te_x, te_y, te_z ) || host != null) && side != ForgeDirection.UNKNOWN ) - return place( held, te_x, te_y, te_z, side.getOpposite().ordinal(), player, world, - pass == PlaceType.INTERACT_FIRST_PASS ? PlaceType.INTERACT_SECOND_PASS : PlaceType.PLACE_ITEM, depth + 1 ); + if ( ( blkID == null || blkID.isReplaceable( world, te_x, te_y, te_z ) || host != null ) && side != ForgeDirection.UNKNOWN ) + return place( held, te_x, te_y, te_z, side.getOpposite().ordinal(), player, world, pass == PlaceType.INTERACT_FIRST_PASS ? PlaceType.INTERACT_SECOND_PASS : PlaceType.PLACE_ITEM, depth + 1 ); } return false; } @@ -379,10 +326,12 @@ public class PartPlacement ForgeDirection mySide = host.addPart( held, side, player ); if ( mySide != null ) { - SoundType ss = AEApi.instance().blocks().blockMultiPart.block().stepSound; + for ( Block multiPartBlock : multiPart.maybeBlock().asSet() ) + { + final SoundType ss = multiPartBlock.stepSound; - // ss.getPlaceSound() - world.playSoundEffect( 0.5 + x, 0.5 + y, 0.5 + z, ss.func_150496_b(), (ss.getVolume() + 1.0F) / 2.0F, ss.getPitch() * 0.8F ); + world.playSoundEffect( 0.5 + x, 0.5 + y, 0.5 + z, ss.func_150496_b(), ( ss.getVolume() + 1.0F ) / 2.0F, ss.getPitch() * 0.8F ); + } if ( !player.capabilities.isCreativeMode ) { @@ -403,9 +352,7 @@ public class PartPlacement return true; } - public static float eyeHeight = 0.0f; - - private static float getEyeOffset(EntityPlayer p) + private static float getEyeOffset( EntityPlayer p ) { if ( p.worldObj.isRemote ) return Platform.getEyeOffset( p ); @@ -413,7 +360,7 @@ public class PartPlacement return eyeHeight; } - private static SelectedPart selectPart(EntityPlayer player, IPartHost host, Vec3 pos) + private static SelectedPart selectPart( EntityPlayer player, IPartHost host, Vec3 pos ) { CommonHelper.proxy.updateRenderMode( player ); SelectedPart sp = host.selectPart( pos ); @@ -422,10 +369,10 @@ public class PartPlacement return sp; } - public static IFacadePart isFacade(ItemStack held, ForgeDirection side) + public static IFacadePart isFacade( ItemStack held, ForgeDirection side ) { if ( held.getItem() instanceof IFacadeItem ) - return ((IFacadeItem) held.getItem()).createPartFromItemStack( held, side ); + return ( (IFacadeItem) held.getItem() ).createPartFromItemStack( held, side ); if ( AppEng.instance.isIntegrationEnabled( IntegrationType.BC ) ) { @@ -437,4 +384,66 @@ public class PartPlacement return null; } + @SubscribeEvent + public void playerInteract( TickEvent.ClientTickEvent event ) + { + this.wasCanceled = false; + } + + @SubscribeEvent + public void playerInteract( PlayerInteractEvent event ) + { + if ( event.action == Action.RIGHT_CLICK_AIR && event.entityPlayer.worldObj.isRemote ) + { + // re-check to see if this event was already channeled, cause these two events are really stupid... + MovingObjectPosition mop = Platform.rayTrace( event.entityPlayer, true, false ); + Minecraft mc = Minecraft.getMinecraft(); + + float f = 1.0F; + double d0 = mc.playerController.getBlockReachDistance(); + Vec3 vec3 = mc.renderViewEntity.getPosition( f ); + + if ( mop != null && mop.hitVec.distanceTo( vec3 ) < d0 ) + { + World w = event.entity.worldObj; + TileEntity te = w.getTileEntity( mop.blockX, mop.blockY, mop.blockZ ); + if ( te instanceof IPartHost && this.wasCanceled ) + event.setCanceled( true ); + } + else + { + ItemStack held = event.entityPlayer.getHeldItem(); + final IItems items = AEApi.instance().definitions().items(); + + boolean supportedItem = items.memoryCard().isSameAs( held ); + supportedItem |= items.colorApplicator().isSameAs( held ); + + if ( event.entityPlayer.isSneaking() && held != null && supportedItem ) + { + NetworkHandler.instance.sendToServer( new PacketClick( event.x, event.y, event.z, event.face, 0, 0, 0 ) ); + } + } + } + else if ( event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote ) + { + if ( this.placing.get() != null ) + return; + + this.placing.set( event ); + + ItemStack held = event.entityPlayer.getHeldItem(); + if ( place( held, event.x, event.y, event.z, event.face, event.entityPlayer, event.entityPlayer.worldObj, PlaceType.INTERACT_FIRST_PASS, 0 ) ) + { + event.setCanceled( true ); + this.wasCanceled = true; + } + + this.placing.set( null ); + } + } + + public enum PlaceType + { + PLACE_ITEM, INTERACT_FIRST_PASS, INTERACT_SECOND_PASS + } } \ No newline at end of file diff --git a/src/main/java/appeng/parts/automation/BlockUpgradeInventory.java b/src/main/java/appeng/parts/automation/BlockUpgradeInventory.java new file mode 100644 index 000000000..13e128f10 --- /dev/null +++ b/src/main/java/appeng/parts/automation/BlockUpgradeInventory.java @@ -0,0 +1,41 @@ +package appeng.parts.automation; + + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +import appeng.api.config.Upgrades; +import appeng.tile.inventory.IAEAppEngInventory; + + +public class BlockUpgradeInventory extends UpgradeInventory +{ + private final Block block; + + public BlockUpgradeInventory( Block block, IAEAppEngInventory parent, int s ) + { + super( parent, s ); + this.block = block; + } + + @Override + public int getMaxInstalled( Upgrades upgrades ) + { + int max = 0; + + for ( ItemStack is : upgrades.getSupported().keySet() ) + { + final Item encodedItem = is.getItem(); + + if ( encodedItem instanceof ItemBlock && Block.getBlockFromItem( encodedItem ) == this.block ) + { + max = upgrades.getSupported().get( is ); + break; + } + } + + return max; + } +} diff --git a/src/main/java/appeng/parts/automation/DefinitionUpgradeInventory.java b/src/main/java/appeng/parts/automation/DefinitionUpgradeInventory.java new file mode 100644 index 000000000..28889da01 --- /dev/null +++ b/src/main/java/appeng/parts/automation/DefinitionUpgradeInventory.java @@ -0,0 +1,38 @@ +package appeng.parts.automation; + + +import net.minecraft.item.ItemStack; + +import appeng.api.config.Upgrades; +import appeng.api.definitions.IItemDefinition; +import appeng.tile.inventory.IAEAppEngInventory; + + +public final class DefinitionUpgradeInventory extends UpgradeInventory +{ + private final IItemDefinition definition; + + public DefinitionUpgradeInventory( IItemDefinition definition, IAEAppEngInventory parent, int s ) + { + super( parent, s ); + + this.definition = definition; + } + + @Override + public int getMaxInstalled( Upgrades upgrades ) + { + int max = 0; + + for ( ItemStack stack : upgrades.getSupported().keySet() ) + { + if ( this.definition.isSameAs( stack ) ) + { + max = upgrades.getSupported().get( stack ); + break; + } + } + + return max; + } +} diff --git a/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java b/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java index e8fa7d4d8..9d5e21cb3 100644 --- a/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java +++ b/src/main/java/appeng/parts/automation/PartAnnihilationPlane.java @@ -69,14 +69,13 @@ import appeng.util.item.AEItemStack; public class PartAnnihilationPlane extends PartBasicState implements IGridTickable, Callable { - - private boolean isAccepting = true; private final BaseActionSource mySrc = new MachineSource( this ); + private boolean isAccepting = true; private boolean breaking = false; public PartAnnihilationPlane( ItemStack is ) { - super( PartAnnihilationPlane.class, is ); + super( is ); } @Override @@ -90,9 +89,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab @SideOnly( Side.CLIENT ) public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ) { - rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(), - CableBusTextures.PartTransitionPlaneBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartPlaneSides.getIcon(), - CableBusTextures.PartPlaneSides.getIcon() ); + rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartTransitionPlaneBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon() ); rh.setBounds( 1, 1, 15, 15, 15, 16 ); rh.renderInventoryBox( renderer ); @@ -138,16 +135,12 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab final boolean isActive = ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) == ( this.POWERED_FLAG | this.CHANNEL_FLAG ); this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); - rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(), - CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockAnnihilationPlaneOn.getIcon() : this.is.getIconIndex(), - CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon() ); + rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockAnnihilationPlaneOn.getIcon() : this.is.getIconIndex(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon() ); rh.setBounds( minX, minY, 15, maxX, maxY, 16 ); rh.renderBlock( x, y, z, renderer ); - rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), - CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockAnnihilationPlaneOn.getIcon() : this.is.getIconIndex(), - CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() ); + rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockAnnihilationPlaneOn.getIcon() : this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() ); rh.setBounds( 5, 5, 14, 11, 11, 15 ); rh.renderBlock( x, y, z, renderer ); @@ -159,12 +152,87 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab { if ( blockTileEntity instanceof IPartHost ) { - final IPart p = ( ( IPartHost ) blockTileEntity ).getPart( side ); + final IPart p = ( (IPartHost) blockTileEntity ).getPart( side ); return p instanceof PartAnnihilationPlane; } return false; } + @Override + public void onNeighborChanged() + { + this.isAccepting = true; + try + { + this.proxy.getTick().alertDevice( this.proxy.getNode() ); + } + catch ( final GridAccessException e ) + { + // :P + } + } + + @Override + public void onEntityCollision( Entity entity ) + { + if ( this.isAccepting && entity instanceof EntityItem && !entity.isDead && Platform.isServer() && this.proxy.isActive() ) + { + boolean capture = false; + + switch ( this.side ) + { + case DOWN: + case UP: + if ( entity.posX > this.tile.xCoord && entity.posX < this.tile.xCoord + 1 ) + { + if ( entity.posZ > this.tile.zCoord && entity.posZ < this.tile.zCoord + 1 ) + { + if ( ( entity.posY > this.tile.yCoord + 0.9 && this.side == ForgeDirection.UP ) || ( entity.posY < this.tile.yCoord + 0.1 && this.side == ForgeDirection.DOWN ) ) + { + capture = true; + } + } + } + break; + case SOUTH: + case NORTH: + if ( entity.posX > this.tile.xCoord && entity.posX < this.tile.xCoord + 1 ) + { + if ( entity.posY > this.tile.yCoord && entity.posY < this.tile.yCoord + 1 ) + { + if ( ( entity.posZ > this.tile.zCoord + 0.9 && this.side == ForgeDirection.SOUTH ) || ( entity.posZ < this.tile.zCoord + 0.1 && this.side == ForgeDirection.NORTH ) ) + { + capture = true; + } + } + } + break; + case EAST: + case WEST: + if ( entity.posZ > this.tile.zCoord && entity.posZ < this.tile.zCoord + 1 ) + { + if ( entity.posY > this.tile.yCoord && entity.posY < this.tile.yCoord + 1 ) + { + if ( ( entity.posX > this.tile.xCoord + 0.9 && this.side == ForgeDirection.EAST ) || ( entity.posX < this.tile.xCoord + 0.1 && this.side == ForgeDirection.WEST ) ) + { + capture = true; + } + } + } + break; + default: + // umm? + break; + } + + if ( capture ) + { + ServerHelper.proxy.sendToAllNearExcept( null, this.tile.xCoord, this.tile.yCoord, this.tile.zCoord, 64, this.tile.getWorldObj(), new PacketTransitionEffect( entity.posX, entity.posY, entity.posZ, this.side, false ) ); + this.storeEntityItem( (EntityItem) entity ); + } + } + } + @Override public void getBoxes( IPartCollisionHelper bch ) { @@ -228,6 +296,61 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab return this.isAccepting; } + /** + * Stores an {@link EntityItem} inside the network and either marks it as dead or sets it to the leftover stackSize. + * + * @param entityItem {@link EntityItem} to store + */ + private void storeEntityItem( EntityItem entityItem ) + { + if ( !entityItem.isDead ) + { + this.storeItemStack( entityItem.getEntityItem() ); + entityItem.setDead(); + } + } + + /** + * Stores an {@link ItemStack} inside the network. + * + * @param item {@link ItemStack} to store + */ + private void storeItemStack( ItemStack item ) + { + final IAEItemStack itemToStore = AEItemStack.create( item ); + try + { + final IStorageGrid storage = this.proxy.getStorage(); + final IEnergyGrid energy = this.proxy.getEnergy(); + final IAEItemStack overflow = Platform.poweredInsert( energy, storage.getItemInventory(), itemToStore, this.mySrc ); + + this.spawnOverflowItemStack( overflow ); + + this.isAccepting = overflow == null; + } + catch ( final GridAccessException e1 ) + { + // :P + } + } + + private void spawnOverflowItemStack( IAEItemStack overflow ) + { + if ( overflow == null ) + { + return; + } + + final TileEntity tileEntity = this.getTile(); + final WorldServer world = (WorldServer) tileEntity.getWorldObj(); + + final int x = tileEntity.xCoord + this.side.offsetX; + final int y = tileEntity.yCoord + this.side.offsetY; + final int z = tileEntity.zCoord + this.side.offsetZ; + + Platform.spawnDrops( world, x, y, z, Lists.newArrayList( overflow.getItemStack() ) ); + } + @Override @MENetworkEventSubscribe public void chanRender( MENetworkChannelsChanged c ) @@ -251,7 +374,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab try { final TileEntity te = this.getTile(); - final WorldServer w = ( WorldServer ) te.getWorldObj(); + final WorldServer w = (WorldServer) te.getWorldObj(); final int x = te.xCoord + this.side.offsetX; final int y = te.yCoord + this.side.offsetY; @@ -262,8 +385,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab final IEnergyGrid energy = this.proxy.getEnergy(); final Material mat = blk.getMaterial(); - final boolean ignore = mat == Material.air || mat == Material.lava || mat == Material.water || mat.isLiquid() || blk == Blocks.bedrock - || blk == Blocks.end_portal || blk == Blocks.end_portal_frame || blk == Blocks.command_block; + final boolean ignore = mat == Material.air || mat == Material.lava || mat == Material.water || mat.isLiquid() || blk == Blocks.bedrock || blk == Blocks.end_portal || blk == Blocks.end_portal_frame || blk == Blocks.command_block; if ( !ignore && !w.isAirBlock( x, y, z ) && w.blockExists( x, y, z ) && w.canMineBlock( Platform.getPlayer( w ), x, y, z ) ) { @@ -294,7 +416,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab { if ( ei instanceof EntityItem ) { - final EntityItem entityItem = ( EntityItem ) ei; + final EntityItem entityItem = (EntityItem) ei; this.storeEntityItem( entityItem ); } } @@ -333,85 +455,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab } @Override - public void onNeighborChanged() - { - this.isAccepting = true; - try - { - this.proxy.getTick().alertDevice( this.proxy.getNode() ); - } - catch ( final GridAccessException e ) - { - // :P - } - } - - @Override - public void onEntityCollision( Entity entity ) - { - if ( this.isAccepting && entity instanceof EntityItem && !entity.isDead && Platform.isServer() && this.proxy.isActive() ) - { - boolean capture = false; - - switch ( this.side ) - { - case DOWN: - case UP: - if ( entity.posX > this.tile.xCoord && entity.posX < this.tile.xCoord + 1 ) - { - if ( entity.posZ > this.tile.zCoord && entity.posZ < this.tile.zCoord + 1 ) - { - if ( ( entity.posY > this.tile.yCoord + 0.9 && this.side == ForgeDirection.UP ) || ( entity.posY < this.tile.yCoord + 0.1 && this.side == ForgeDirection.DOWN ) ) - { - capture = true; - } - } - } - break; - case SOUTH: - case NORTH: - if ( entity.posX > this.tile.xCoord && entity.posX < this.tile.xCoord + 1 ) - { - if ( entity.posY > this.tile.yCoord && entity.posY < this.tile.yCoord + 1 ) - { - if ( ( entity.posZ > this.tile.zCoord + 0.9 && this.side == ForgeDirection.SOUTH ) - || ( entity.posZ < this.tile.zCoord + 0.1 && this.side == ForgeDirection.NORTH ) ) - { - capture = true; - } - } - } - break; - case EAST: - case WEST: - if ( entity.posZ > this.tile.zCoord && entity.posZ < this.tile.zCoord + 1 ) - { - if ( entity.posY > this.tile.yCoord && entity.posY < this.tile.yCoord + 1 ) - { - if ( ( entity.posX > this.tile.xCoord + 0.9 && this.side == ForgeDirection.EAST ) - || ( entity.posX < this.tile.xCoord + 0.1 && this.side == ForgeDirection.WEST ) ) - { - capture = true; - } - } - } - break; - default: - // umm? - break; - } - - if ( capture ) - { - ServerHelper.proxy.sendToAllNearExcept( null, this.tile.xCoord, this.tile.yCoord, this.tile.zCoord, 64, this.tile.getWorldObj(), - new PacketTransitionEffect( entity.posX, entity.posY, entity.posZ, this.side, false ) ); - this.storeEntityItem( ( EntityItem ) entity ); - } - } - } - - @Override - public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) + public TickRateModulation tickingRequest( IGridNode node, int ticksSinceLastCall ) { if ( this.breaking ) { @@ -428,6 +472,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab * It also sets isAccepting to false, if the item can not be stored. * * @param itemStacks an array of {@link ItemStack} to test + * * @return true, if the network can store at least a single item of all drops or no drops are reported */ private boolean canStoreItemStacks( ItemStack[] itemStacks ) @@ -456,63 +501,4 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab this.isAccepting = canStore; return canStore; } - - /** - * Stores an {@link ItemStack} inside the network. - * - * @param item {@link ItemStack} to store - * @return null or leftover {@link IAEItemStack} - */ - private boolean storeItemStack( ItemStack item ) - { - final IAEItemStack itemToStore = AEItemStack.create( item ); - try - { - final IStorageGrid storage = this.proxy.getStorage(); - final IEnergyGrid energy = this.proxy.getEnergy(); - final IAEItemStack overflow = Platform.poweredInsert( energy, storage.getItemInventory(), itemToStore, this.mySrc ); - - this.spawnOverflowItemStack( overflow ); - - this.isAccepting = overflow == null; - return overflow == null || item.stackSize < overflow.getStackSize(); - } - catch ( final GridAccessException e1 ) - { - // :P - } - return false; - } - - /** - * Stores an {@link EntityItem} inside the network and either marks it as dead or sets it to the leftover stackSize. - * - * @param entityItem {@link EntityItem} to store - */ - private void storeEntityItem( EntityItem entityItem ) - { - if ( !entityItem.isDead ) - { - this.storeItemStack( entityItem.getEntityItem() ); - entityItem.setDead(); - } - } - - private void spawnOverflowItemStack( IAEItemStack overflow ) - { - if ( overflow == null ) - { - return; - } - - final TileEntity tileEntity = this.getTile(); - final WorldServer world = ( WorldServer ) tileEntity.getWorldObj(); - - final int x = tileEntity.xCoord + this.side.offsetX; - final int y = tileEntity.yCoord + this.side.offsetY; - final int z = tileEntity.zCoord + this.side.offsetZ; - - Platform.spawnDrops( world, x, y, z, Lists.newArrayList( overflow.getItemStack() ) ); - } - } diff --git a/src/main/java/appeng/parts/automation/PartExportBus.java b/src/main/java/appeng/parts/automation/PartExportBus.java index e65637268..3473338df 100644 --- a/src/main/java/appeng/parts/automation/PartExportBus.java +++ b/src/main/java/appeng/parts/automation/PartExportBus.java @@ -18,8 +18,6 @@ package appeng.parts.automation; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.entity.player.EntityPlayer; @@ -30,6 +28,9 @@ import net.minecraft.util.Vec3; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; + import appeng.api.config.Actionable; import appeng.api.config.FuzzyMode; import appeng.api.config.PowerMultiplier; @@ -56,42 +57,179 @@ import appeng.core.AELog; import appeng.core.settings.TickRates; import appeng.core.sync.GuiBridge; import appeng.helpers.MultiCraftingTracker; +import appeng.helpers.Reflected; import appeng.me.GridAccessException; import appeng.util.InventoryAdaptor; import appeng.util.Platform; import appeng.util.item.AEItemStack; + public class PartExportBus extends PartSharedItemBus implements ICraftingRequester { - final MultiCraftingTracker cratingTracker = new MultiCraftingTracker( this, 9 ); final BaseActionSource mySrc; + long itemToSend = 1; + boolean didSomething = false; - public PartExportBus(ItemStack is) + @Reflected + public PartExportBus( ItemStack is ) { - super( PartExportBus.class, is ); - this.settings.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE ); - this.settings.registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); - this.settings.registerSetting( Settings.CRAFT_ONLY, YesNo.NO ); + super( is ); + + this.getConfigManager().registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE ); + this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); + this.getConfigManager().registerSetting( Settings.CRAFT_ONLY, YesNo.NO ); this.mySrc = new MachineSource( this ); } @Override - public void readFromNBT(NBTTagCompound extra) - { - super.readFromNBT( extra ); - this.cratingTracker.readFromNBT( extra ); - } - - @Override - public void writeToNBT(NBTTagCompound extra) + public void writeToNBT( NBTTagCompound extra ) { super.writeToNBT( extra ); this.cratingTracker.writeToNBT( extra ); } @Override - public boolean onPartActivate(EntityPlayer player, Vec3 pos) + public void readFromNBT( NBTTagCompound extra ) + { + super.readFromNBT( extra ); + this.cratingTracker.readFromNBT( extra ); + } + + @Override + TickRateModulation doBusWork() + { + if ( !this.proxy.isActive() ) + return TickRateModulation.IDLE; + + this.itemToSend = 1; + this.didSomething = false; + + switch ( this.getInstalledUpgrades( Upgrades.SPEED ) ) + { + default: + case 0: + this.itemToSend = 1; + break; + case 1: + this.itemToSend = 8; + break; + case 2: + this.itemToSend = 32; + break; + case 3: + this.itemToSend = 64; + break; + case 4: + this.itemToSend = 96; + break; + } + + try + { + InventoryAdaptor d = this.getHandler(); + IMEMonitor inv = this.proxy.getStorage().getItemInventory(); + IEnergyGrid energy = this.proxy.getEnergy(); + ICraftingGrid cg = this.proxy.getCrafting(); + FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ); + + if ( d != null ) + { + for ( int x = 0; x < this.availableSlots() && this.itemToSend > 0; x++ ) + { + IAEItemStack ais = this.config.getAEStackInSlot( x ); + if ( ais == null || this.itemToSend <= 0 || this.craftOnly() ) + { + if ( this.isCraftingEnabled() ) + this.didSomething = this.cratingTracker.handleCrafting( x, this.itemToSend, ais, d, this.getTile().getWorldObj(), this.proxy.getGrid(), cg, this.mySrc ) || this.didSomething; + continue; + } + + long before = this.itemToSend; + + if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) + { + for ( IAEItemStack o : ImmutableList.copyOf( inv.getStorageList().findFuzzy( ais, fzMode ) ) ) + { + this.pushItemIntoTarget( d, energy, inv, o ); + if ( this.itemToSend <= 0 ) + break; + } + } + else + this.pushItemIntoTarget( d, energy, inv, ais ); + + if ( this.itemToSend == before && this.isCraftingEnabled() ) + this.didSomething = this.cratingTracker.handleCrafting( x, this.itemToSend, ais, d, this.getTile().getWorldObj(), this.proxy.getGrid(), cg, this.mySrc ) || this.didSomething; + } + } + } + catch ( GridAccessException e ) + { + // :P + } + + return this.didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER; + } + + @Override + @SideOnly( Side.CLIENT ) + public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ) + { + + rh.setTexture( CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() ); + + rh.setBounds( 4, 4, 12, 12, 12, 14 ); + rh.renderInventoryBox( renderer ); + + rh.setBounds( 5, 5, 14, 11, 11, 15 ); + rh.renderInventoryBox( renderer ); + + rh.setBounds( 6, 6, 15, 10, 10, 16 ); + rh.renderInventoryBox( renderer ); + } + + @Override + @SideOnly( Side.CLIENT ) + public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ) + { + this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); + rh.setTexture( CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() ); + + rh.setBounds( 4, 4, 12, 12, 12, 14 ); + rh.renderBlock( x, y, z, renderer ); + + rh.setBounds( 5, 5, 14, 11, 11, 15 ); + rh.renderBlock( x, y, z, renderer ); + + rh.setBounds( 6, 6, 15, 10, 10, 16 ); + rh.renderBlock( x, y, z, renderer ); + + rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() ); + + rh.setBounds( 6, 6, 11, 10, 10, 12 ); + rh.renderBlock( x, y, z, renderer ); + + this.renderLights( x, y, z, rh, renderer ); + } + + @Override + public void getBoxes( IPartCollisionHelper bch ) + { + bch.addBox( 4, 4, 12, 12, 12, 14 ); + bch.addBox( 5, 5, 14, 11, 11, 15 ); + bch.addBox( 6, 6, 15, 10, 10, 16 ); + bch.addBox( 6, 6, 11, 10, 10, 12 ); + } + + @Override + public int cableConnectionRenderTo() + { + return 5; + } + + @Override + public boolean onPartActivate( EntityPlayer player, Vec3 pos ) { if ( !player.isSneaking() ) { @@ -106,145 +244,27 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest } @Override - @SideOnly(Side.CLIENT) - public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) + public RedstoneMode getRSMode() { - - rh.setTexture( CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), - this.is.getIconIndex(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() ); - - rh.setBounds( 4, 4, 12, 12, 12, 14 ); - rh.renderInventoryBox( renderer ); - - rh.setBounds( 5, 5, 14, 11, 11, 15 ); - rh.renderInventoryBox( renderer ); - - rh.setBounds( 6, 6, 15, 10, 10, 16 ); - rh.renderInventoryBox( renderer ); + return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ); } @Override - @SideOnly(Side.CLIENT) - public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer) + protected boolean isSleeping() { - this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); - rh.setTexture( CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), - this.is.getIconIndex(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() ); - - rh.setBounds( 4, 4, 12, 12, 12, 14 ); - rh.renderBlock( x, y, z, renderer ); - - rh.setBounds( 5, 5, 14, 11, 11, 15 ); - rh.renderBlock( x, y, z, renderer ); - - rh.setBounds( 6, 6, 15, 10, 10, 16 ); - rh.renderBlock( x, y, z, renderer ); - - rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), - CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), - CableBusTextures.PartMonitorSidesStatus.getIcon() ); - - rh.setBounds( 6, 6, 11, 10, 10, 12 ); - rh.renderBlock( x, y, z, renderer ); - - this.renderLights( x, y, z, rh, renderer ); + return this.getHandler() == null || super.isSleeping(); } @Override - public int cableConnectionRenderTo() + public TickingRequest getTickingRequest( IGridNode node ) { - return 5; + return new TickingRequest( TickRates.ExportBus.min, TickRates.ExportBus.max, this.isSleeping(), false ); } @Override - public void getBoxes(IPartCollisionHelper bch) + public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) { - bch.addBox( 4, 4, 12, 12, 12, 14 ); - bch.addBox( 5, 5, 14, 11, 11, 15 ); - bch.addBox( 6, 6, 15, 10, 10, 16 ); - bch.addBox( 6, 6, 11, 10, 10, 12 ); - } - - long itemToSend = 1; - boolean didSomething = false; - - @Override - TickRateModulation doBusWork() - { - if ( !this.proxy.isActive() ) - return TickRateModulation.IDLE; - - this.itemToSend = 1; - this.didSomething = false; - - switch (this.getInstalledUpgrades( Upgrades.SPEED )) - { - default: - case 0: - this.itemToSend = 1; - break; - case 1: - this.itemToSend = 8; - break; - case 2: - this.itemToSend = 32; - break; - case 3: - this.itemToSend = 64; - break; - case 4: - this.itemToSend = 96; - break; - } - - try - { - InventoryAdaptor d = this.getHandler(); - IMEMonitor inv = this.proxy.getStorage().getItemInventory(); - IEnergyGrid energy = this.proxy.getEnergy(); - ICraftingGrid cg = this.proxy.getCrafting(); - FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ); - - if ( d != null ) - { - for (int x = 0; x < this.availableSlots() && this.itemToSend > 0; x++) - { - IAEItemStack ais = this.config.getAEStackInSlot( x ); - if ( ais == null || this.itemToSend <= 0 || this.craftOnly() ) - { - if ( this.isCraftingEnabled() ) - this.didSomething = this.cratingTracker.handleCrafting( x, this.itemToSend, ais, d, this.getTile().getWorldObj(), this.proxy.getGrid(), cg, this.mySrc ) - || this.didSomething; - continue; - } - - long before = this.itemToSend; - - if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) - { - for (IAEItemStack o : ImmutableList.copyOf( inv.getStorageList().findFuzzy( ais, fzMode ) )) - { - this.pushItemIntoTarget( d, energy, inv, o ); - if ( this.itemToSend <= 0 ) - break; - } - } - else - this.pushItemIntoTarget( d, energy, inv, ais ); - - if ( this.itemToSend == before && this.isCraftingEnabled() ) - this.didSomething = this.cratingTracker.handleCrafting( x, this.itemToSend, ais, d, this.getTile().getWorldObj(), this.proxy.getGrid(), cg, this.mySrc ) - || this.didSomething; - } - } - - } - catch (GridAccessException e) - { - // :P - } - - return this.didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER; + return this.doBusWork(); } private boolean craftOnly() @@ -257,7 +277,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest return this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0; } - private void pushItemIntoTarget(InventoryAdaptor d, IEnergyGrid energy, IMEInventory inv, IAEItemStack ais) + private void pushItemIntoTarget( InventoryAdaptor d, IEnergyGrid energy, IMEInventory inv, IAEItemStack ais ) { ItemStack is = ais.getItemStack(); is.stackSize = (int) this.itemToSend; @@ -284,12 +304,17 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest else this.didSomething = true; } - } } @Override - public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) + public ImmutableSet getRequestedJobs() + { + return this.cratingTracker.getRequestedJobs(); + } + + @Override + public IAEItemStack injectCraftedItems( ICraftingLink link, IAEItemStack items, Actionable mode ) { InventoryAdaptor d = this.getHandler(); @@ -308,7 +333,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest } } } - catch (GridAccessException e) + catch ( GridAccessException e ) { AELog.error( e ); } @@ -317,39 +342,8 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest } @Override - public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) - { - return this.doBusWork(); - } - - @Override - public RedstoneMode getRSMode() - { - return (RedstoneMode) this.settings.getSetting( Settings.REDSTONE_CONTROLLED ); - } - - @Override - protected boolean isSleeping() - { - return this.getHandler() == null || super.isSleeping(); - } - - @Override - public TickingRequest getTickingRequest(IGridNode node) - { - return new TickingRequest( TickRates.ExportBus.min, TickRates.ExportBus.max, this.isSleeping(), false ); - } - - @Override - public ImmutableSet getRequestedJobs() - { - return this.cratingTracker.getRequestedJobs(); - } - - @Override - public void jobStateChange(ICraftingLink link) + public void jobStateChange( ICraftingLink link ) { this.cratingTracker.jobStateChange( link ); } - } diff --git a/src/main/java/appeng/parts/automation/PartFormationPlane.java b/src/main/java/appeng/parts/automation/PartFormationPlane.java index dec6561dd..cc46e4dda 100644 --- a/src/main/java/appeng/parts/automation/PartFormationPlane.java +++ b/src/main/java/appeng/parts/automation/PartFormationPlane.java @@ -85,42 +85,81 @@ import appeng.util.prioitylist.PrecisePriorityList; public class PartFormationPlane extends PartUpgradeable implements ICellContainer, IPriorityHost, IMEInventory { - + final MEInventoryHandler myHandler = new MEInventoryHandler( this, StorageChannel.ITEMS ); + final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 ); int priority = 0; boolean wasActive = false; boolean blocked = false; - final MEInventoryHandler myHandler = new MEInventoryHandler( this, StorageChannel.ITEMS ); - final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 ); public PartFormationPlane( ItemStack is ) { - super( PartFormationPlane.class, is ); - this.settings.registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); - this.settings.registerSetting( Settings.PLACE_BLOCK, YesNo.YES ); + super( is ); + + this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); + this.getConfigManager().registerSetting( Settings.PLACE_BLOCK, YesNo.YES ); this.updateHandler(); } - @Override - public boolean onPartActivate( EntityPlayer player, Vec3 pos ) - { - if ( !player.isSneaking() ) - { - if ( Platform.isClient() ) - return true; - Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_FORMATION_PLANE ); - return true; + private void updateHandler() + { + this.myHandler.setBaseAccess( AccessRestriction.WRITE ); + ; + this.myHandler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST ); + this.myHandler.setPriority( this.priority ); + + IItemList priorityList = AEApi.instance().storage().createItemList(); + + int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9; + for ( int x = 0; x < this.Config.getSizeInventory() && x < slotsToUse; x++ ) + { + IAEItemStack is = this.Config.getAEStackInSlot( x ); + if ( is != null ) + priorityList.add( is ); } - return false; + if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) + this.myHandler.setPartitionList( new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) ); + else + this.myHandler.setPartitionList( new PrecisePriorityList( priorityList ) ); + + try + { + this.proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() ); + } + catch ( GridAccessException e ) + { + // :P + } } + @Override protected int getUpgradeSlots() { return 5; } + + @Override + public void writeToNBT( NBTTagCompound data ) + { + super.writeToNBT( data ); + this.Config.writeToNBT( data, "config" ); + data.setInteger( "priority", this.priority ); + } + + + @Override + public void readFromNBT( NBTTagCompound data ) + { + super.readFromNBT( data ); + this.Config.readFromNBT( data, "config" ); + this.priority = data.getInteger( "priority" ); + this.updateHandler(); + } + + @Override public IInventory getInventoryByName( String name ) { @@ -130,6 +169,32 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine return super.getInventoryByName( name ); } + + @Override + public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue ) + { + this.updateHandler(); + this.host.markForSave(); + } + + + @Override + public void upgradesChanged() + { + this.updateHandler(); + } + + + @Override + public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack ) + { + super.onChangeInventory( inv, slot, mc, removedStack, newStack ); + + if ( inv == this.Config ) + this.updateHandler(); + } + + @Override @MENetworkEventSubscribe public void powerRender( MENetworkPowerStatusChange c ) @@ -143,6 +208,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine } } + @MENetworkEventSubscribe public void updateChannels( MENetworkChannelsChanged changedChannels ) { @@ -155,13 +221,12 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine } } + @Override @SideOnly( Side.CLIENT ) public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ) { - rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(), - CableBusTextures.PartTransitionPlaneBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartPlaneSides.getIcon(), - CableBusTextures.PartPlaneSides.getIcon() ); + rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartTransitionPlaneBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon() ); rh.setBounds( 1, 1, 15, 15, 15, 16 ); rh.renderInventoryBox( renderer ); @@ -170,6 +235,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine rh.renderInventoryBox( renderer ); } + @Override @SideOnly( Side.CLIENT ) public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ) @@ -199,16 +265,12 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine boolean isActive = ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) == ( this.POWERED_FLAG | this.CHANNEL_FLAG ); this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); - rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(), - CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : this.is.getIconIndex(), - CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon() ); + rh.setTexture( CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : this.is.getIconIndex(), CableBusTextures.PartPlaneSides.getIcon(), CableBusTextures.PartPlaneSides.getIcon() ); rh.setBounds( minX, minY, 15, maxX, maxY, 16 ); rh.renderBlock( x, y, z, renderer ); - rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), - CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : this.is.getIconIndex(), - CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() ); + rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartTransitionPlaneBack.getIcon(), isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() ); rh.setBounds( 5, 5, 14, 11, 11, 15 ); rh.renderBlock( x, y, z, renderer ); @@ -216,16 +278,33 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine this.renderLights( x, y, z, rh, renderer ); } + private boolean isTransitionPlane( TileEntity blockTileEntity, ForgeDirection side ) { if ( blockTileEntity instanceof IPartHost ) { - IPart p = ( ( IPartHost ) blockTileEntity ).getPart( side ); + IPart p = ( (IPartHost) blockTileEntity ).getPart( side ); return p instanceof PartFormationPlane; } return false; } + + @Override + public void onNeighborChanged() + { + TileEntity te = this.host.getTile(); + World w = te.getWorldObj(); + ForgeDirection side = this.side; + + int x = te.xCoord + side.offsetX; + int y = te.yCoord + side.offsetY; + int z = te.zCoord + side.offsetZ; + + this.blocked = !w.getBlock( x, y, z ).isReplaceable( w, x, y, z ); + } + + @Override public void getBoxes( IPartCollisionHelper bch ) { @@ -263,12 +342,30 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine bch.addBox( minX, minY, 15, maxX, maxY, 16 ); } + @Override public int cableConnectionRenderTo() { return 1; } + + @Override + public boolean onPartActivate( EntityPlayer player, Vec3 pos ) + { + if ( !player.isSneaking() ) + { + if ( Platform.isClient() ) + return true; + + Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_FORMATION_PLANE ); + return true; + } + + return false; + } + + @Override public List getCellArray( StorageChannel channel ) { @@ -281,13 +378,14 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine return new ArrayList(); } + @Override - public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue ) + public int getPriority() { - this.updateHandler(); - this.host.markForSave(); + return this.priority; } + @Override public void setPriority( int newValue ) { @@ -296,92 +394,6 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine this.updateHandler(); } - @Override - public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack ) - { - super.onChangeInventory( inv, slot, mc, removedStack, newStack ); - - if ( inv == this.Config ) - this.updateHandler(); - } - - @Override - public void upgradesChanged() - { - this.updateHandler(); - } - - private void updateHandler() - { - this.myHandler.setBaseAccess( AccessRestriction.WRITE ); - this.myHandler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST ); - this.myHandler.setPriority( this.priority ); - - IItemList priorityList = AEApi.instance().storage().createItemList(); - - int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9; - for ( int x = 0; x < this.Config.getSizeInventory() && x < slotsToUse; x++ ) - { - IAEItemStack is = this.Config.getAEStackInSlot( x ); - if ( is != null ) - priorityList.add( is ); - } - - if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) - this.myHandler.setPartitionList( new FuzzyPriorityList( priorityList, ( FuzzyMode ) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) ); - else - this.myHandler.setPartitionList( new PrecisePriorityList( priorityList ) ); - - try - { - this.proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() ); - } - catch ( GridAccessException e ) - { - // :P - } - } - - @Override - public void writeToNBT( NBTTagCompound data ) - { - super.writeToNBT( data ); - this.Config.writeToNBT( data, "config" ); - data.setInteger( "priority", this.priority ); - } - - @Override - public void readFromNBT( NBTTagCompound data ) - { - super.readFromNBT( data ); - this.Config.readFromNBT( data, "config" ); - this.priority = data.getInteger( "priority" ); - this.updateHandler(); - } - - @Override - public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src ) - { - return null; - } - - @Override - public IItemList getAvailableItems( IItemList out ) - { - return out; - } - - @Override - public StorageChannel getChannel() - { - return StorageChannel.ITEMS; - } - - @Override - public int getPriority() - { - return this.priority; - } @Override public void blinkCell( int slot ) @@ -389,19 +401,6 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine // :P } - @Override - public void onNeighborChanged() - { - TileEntity te = this.host.getTile(); - World w = te.getWorldObj(); - ForgeDirection side = this.side; - - int x = te.xCoord + side.offsetX; - int y = te.yCoord + side.offsetY; - int z = te.zCoord + side.offsetZ; - - this.blocked = !w.getBlock( x, y, z ).isReplaceable( w, x, y, z ); - } @Override public IAEItemStack injectItems( IAEItemStack input, Actionable type, BaseActionSource src ) @@ -409,7 +408,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine if ( this.blocked || input == null || input.getStackSize() <= 0 ) return input; - YesNo placeBlock = ( YesNo ) this.getConfigManager().getSetting( Settings.PLACE_BLOCK ); + YesNo placeBlock = (YesNo) this.getConfigManager().getSetting( Settings.PLACE_BLOCK ); ItemStack is = input.getItemStack(); Item i = is.getItem(); @@ -427,10 +426,9 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine if ( w.getBlock( x, y, z ).isReplaceable( w, x, y, z ) ) { - if ( placeBlock == YesNo.YES && ( i instanceof ItemBlock || i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemFirework || i instanceof IPartItem - || i instanceof ItemReed ) ) + if ( placeBlock == YesNo.YES && ( i instanceof ItemBlock || i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemFirework || i instanceof IPartItem || i instanceof ItemReed ) ) { - EntityPlayer player = Platform.getPlayer( ( WorldServer ) w ); + EntityPlayer player = Platform.getPlayer( (WorldServer) w ); Platform.configurePlayer( player, side, this.tile ); if ( i instanceof ItemFirework ) @@ -451,12 +449,10 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine boolean Worked = false; if ( side.offsetX == 0 && side.offsetZ == 0 ) - Worked = i.onItemUse( is, player, w, x + side.offsetX, y + side.offsetY, z + side.offsetZ, side.getOpposite().ordinal(), - side.offsetX, side.offsetY, side.offsetZ ); + Worked = i.onItemUse( is, player, w, x + side.offsetX, y + side.offsetY, z + side.offsetZ, side.getOpposite().ordinal(), side.offsetX, side.offsetY, side.offsetZ ); if ( !Worked && side.offsetX == 0 && side.offsetZ == 0 ) - Worked = i.onItemUse( is, player, w, x - side.offsetX, y - side.offsetY, z - side.offsetZ, side.ordinal(), side.offsetX, - side.offsetY, side.offsetZ ); + Worked = i.onItemUse( is, player, w, x - side.offsetX, y - side.offsetY, z - side.offsetZ, side.ordinal(), side.offsetX, side.offsetY, side.offsetZ ); if ( !Worked && side.offsetY == 0 ) Worked = i.onItemUse( is, player, w, x, y - 1, z, ForgeDirection.UP.ordinal(), side.offsetX, side.offsetY, side.offsetZ ); @@ -488,12 +484,12 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine if ( type == Actionable.MODULATE ) { - is.stackSize = ( int ) maxStorage; + is.stackSize = (int) maxStorage; EntityItem ei = new EntityItem( w, // w - ( ( side.offsetX != 0 ? 0.0 : 0.7 ) * ( Platform.getRandomFloat() - 0.5f ) ) + 0.5 + side.offsetX * -0.3 + x, // spawn - ( ( side.offsetY != 0 ? 0.0 : 0.7 ) * ( Platform.getRandomFloat() - 0.5f ) ) + 0.5 + side.offsetY * -0.3 + y, // spawn - ( ( side.offsetZ != 0 ? 0.0 : 0.7 ) * ( Platform.getRandomFloat() - 0.5f ) ) + 0.5 + side.offsetZ * -0.3 + z, // spawn - is.copy() ); + ( ( side.offsetX != 0 ? 0.0 : 0.7 ) * ( Platform.getRandomFloat() - 0.5f ) ) + 0.5 + side.offsetX * -0.3 + x, // spawn + ( ( side.offsetY != 0 ? 0.0 : 0.7 ) * ( Platform.getRandomFloat() - 0.5f ) ) + 0.5 + side.offsetY * -0.3 + y, // spawn + ( ( side.offsetZ != 0 ? 0.0 : 0.7 ) * ( Platform.getRandomFloat() - 0.5f ) ) + 0.5 + side.offsetZ * -0.3 + z, // spawn + is.copy() ); Entity result = ei; @@ -515,7 +511,6 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine result.setDead(); worked = false; } - } } else @@ -537,6 +532,28 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine return input; } + + @Override + public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src ) + { + return null; + } + + + @Override + public IItemList getAvailableItems( IItemList out ) + { + return out; + } + + + @Override + public StorageChannel getChannel() + { + return StorageChannel.ITEMS; + } + + @Override public void saveChanges( IMEInventory cellInventory ) { diff --git a/src/main/java/appeng/parts/automation/PartImportBus.java b/src/main/java/appeng/parts/automation/PartImportBus.java index 91c8e3a15..ff36fdd4b 100644 --- a/src/main/java/appeng/parts/automation/PartImportBus.java +++ b/src/main/java/appeng/parts/automation/PartImportBus.java @@ -18,6 +18,7 @@ package appeng.parts.automation; + import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -48,27 +49,98 @@ import appeng.api.storage.data.IAEItemStack; import appeng.client.texture.CableBusTextures; import appeng.core.settings.TickRates; import appeng.core.sync.GuiBridge; +import appeng.helpers.Reflected; import appeng.me.GridAccessException; import appeng.util.InventoryAdaptor; import appeng.util.Platform; import appeng.util.inv.IInventoryDestination; + public class PartImportBus extends PartSharedItemBus implements IInventoryDestination { - - final BaseActionSource mySrc; + private final BaseActionSource source; IMEInventory destination = null; IAEItemStack lastItemChecked = null; + private int itemToSend; // used in tickingRequest + private boolean worked; // used in tickingRequest - public PartImportBus(ItemStack is) { - super( PartImportBus.class, is ); - this.settings.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE ); - this.settings.registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); - this.mySrc = new MachineSource( this ); + @Reflected + public PartImportBus( ItemStack is ) + { + super( is ); + + this.getConfigManager().registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE ); + this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); + this.source = new MachineSource( this ); } @Override - public boolean onPartActivate(EntityPlayer player, Vec3 pos) + public boolean canInsert( ItemStack stack ) + { + if ( stack == null || stack.getItem() == null ) + return false; + + IAEItemStack out = this.destination.injectItems( this.lastItemChecked = AEApi.instance().storage().createItemStack( stack ), Actionable.SIMULATE, this.source ); + if ( out == null ) + return true; + return out.getStackSize() != stack.stackSize; + } + + @Override + @SideOnly( Side.CLIENT ) + public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ) + { + rh.setTexture( CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon() ); + + rh.setBounds( 3, 3, 15, 13, 13, 16 ); + rh.renderInventoryBox( renderer ); + + rh.setBounds( 4, 4, 14, 12, 12, 15 ); + rh.renderInventoryBox( renderer ); + + rh.setBounds( 5, 5, 13, 11, 11, 14 ); + rh.renderInventoryBox( renderer ); + } + + @Override + @SideOnly( Side.CLIENT ) + public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ) + { + this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); + rh.setTexture( CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon() ); + + rh.setBounds( 4, 4, 14, 12, 12, 16 ); + rh.renderBlock( x, y, z, renderer ); + + rh.setBounds( 5, 5, 13, 11, 11, 14 ); + rh.renderBlock( x, y, z, renderer ); + + rh.setBounds( 6, 6, 12, 10, 10, 13 ); + rh.renderBlock( x, y, z, renderer ); + rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() ); + + rh.setBounds( 6, 6, 11, 10, 10, 12 ); + rh.renderBlock( x, y, z, renderer ); + + this.renderLights( x, y, z, rh, renderer ); + } + + @Override + public void getBoxes( IPartCollisionHelper bch ) + { + bch.addBox( 6, 6, 11, 10, 10, 13 ); + bch.addBox( 5, 5, 13, 11, 11, 14 ); + bch.addBox( 4, 4, 14, 12, 12, 16 ); + } + + @Override + public int cableConnectionRenderTo() + { + return 5; + } + + @Override + public boolean onPartActivate( EntityPlayer player, Vec3 pos ) { if ( !player.isSneaking() ) { @@ -83,88 +155,16 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin } @Override - public boolean canInsert(ItemStack stack) - { - if ( stack == null || stack.getItem() == null ) - return false; - - IAEItemStack out = this.destination.injectItems( this.lastItemChecked = AEApi.instance().storage().createItemStack( stack ), Actionable.SIMULATE, this.mySrc ); - if ( out == null ) - return true; - return out.getStackSize() != stack.stackSize; - } - - private IInventoryDestination configDestination( IMEMonitor itemInventory ) - { - this.destination = itemInventory; - return this; - } - - @Override - @SideOnly(Side.CLIENT) - public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) - { - rh.setTexture( CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), - this.is.getIconIndex(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon() ); - - rh.setBounds( 3, 3, 15, 13, 13, 16 ); - rh.renderInventoryBox( renderer ); - - rh.setBounds( 4, 4, 14, 12, 12, 15 ); - rh.renderInventoryBox( renderer ); - - rh.setBounds( 5, 5, 13, 11, 11, 14 ); - rh.renderInventoryBox( renderer ); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer) - { - this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); - rh.setTexture( CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), - this.is.getIconIndex(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon() ); - - rh.setBounds( 4, 4, 14, 12, 12, 16 ); - rh.renderBlock( x, y, z, renderer ); - - rh.setBounds( 5, 5, 13, 11, 11, 14 ); - rh.renderBlock( x, y, z, renderer ); - - rh.setBounds( 6, 6, 12, 10, 10, 13 ); - rh.renderBlock( x, y, z, renderer ); - rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), - CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), - CableBusTextures.PartMonitorSidesStatus.getIcon() ); - - rh.setBounds( 6, 6, 11, 10, 10, 12 ); - rh.renderBlock( x, y, z, renderer ); - - this.renderLights( x, y, z, rh, renderer ); - } - - @Override - public void getBoxes(IPartCollisionHelper bch) - { - bch.addBox( 6, 6, 11, 10, 10, 13 ); - bch.addBox( 5, 5, 13, 11, 11, 14 ); - bch.addBox( 4, 4, 14, 12, 12, 16 ); - } - - @Override - public int cableConnectionRenderTo() - { - return 5; - } - - @Override - public TickingRequest getTickingRequest(IGridNode node) + public TickingRequest getTickingRequest( IGridNode node ) { return new TickingRequest( TickRates.ImportBus.min, TickRates.ImportBus.max, this.getHandler() == null, false ); } - private int itemToSend; // used in tickingRequest - private boolean worked; // used in tickingRequest + @Override + public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) + { + return this.doBusWork(); + } @Override TickRateModulation doBusWork() @@ -181,38 +181,38 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin { try { - switch (this.getInstalledUpgrades( Upgrades.SPEED )) + switch ( this.getInstalledUpgrades( Upgrades.SPEED ) ) { - default: - case 0: - this.itemToSend = 1; - break; - case 1: - this.itemToSend = 8; - break; - case 2: - this.itemToSend = 32; - break; - case 3: - this.itemToSend = 64; - break; - case 4: - this.itemToSend = 96; - break; + default: + case 0: + this.itemToSend = 1; + break; + case 1: + this.itemToSend = 8; + break; + case 2: + this.itemToSend = 32; + break; + case 3: + this.itemToSend = 64; + break; + case 4: + this.itemToSend = 96; + break; } - this.itemToSend = Math.min( this.itemToSend, (int) (0.01 + this.proxy.getEnergy().extractAEPower( this.itemToSend, Actionable.SIMULATE, PowerMultiplier.CONFIG )) ); + this.itemToSend = Math.min( this.itemToSend, (int) ( 0.01 + this.proxy.getEnergy().extractAEPower( this.itemToSend, Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) ); IMEMonitor inv = this.proxy.getStorage().getItemInventory(); IEnergyGrid energy = this.proxy.getEnergy(); boolean Configured = false; - for (int x = 0; x < this.availableSlots(); x++) + for ( int x = 0; x < this.availableSlots(); x++ ) { IAEItemStack ais = this.config.getAEStackInSlot( x ); if ( ais != null && this.itemToSend > 0 ) { Configured = true; - while (this.itemToSend > 0) + while ( this.itemToSend > 0 ) { if ( this.importStuff( myAdaptor, ais, inv, energy, fzMode ) ) break; @@ -222,14 +222,14 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin if ( !Configured ) { - while (this.itemToSend > 0) + while ( this.itemToSend > 0 ) { if ( this.importStuff( myAdaptor, null, inv, energy, fzMode ) ) break; } } } - catch (GridAccessException e) + catch ( GridAccessException e ) { // :3 } @@ -240,13 +240,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin return this.worked ? TickRateModulation.FASTER : TickRateModulation.SLOWER; } - @Override - public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) - { - return this.doBusWork(); - } - - private boolean importStuff(InventoryAdaptor myAdaptor, IAEItemStack whatToImport, IMEMonitor inv, IEnergySource energy, FuzzyMode fzMode) + private boolean importStuff( InventoryAdaptor myAdaptor, IAEItemStack whatToImport, IMEMonitor inv, IEnergySource energy, FuzzyMode fzMode ) { int toSend = this.itemToSend; @@ -261,7 +255,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin if ( newItems != null ) { - newItems.stackSize = (int) (Math.min( newItems.stackSize, energy.extractAEPower( newItems.stackSize, Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) + 0.01); + newItems.stackSize = (int) ( Math.min( newItems.stackSize, energy.extractAEPower( newItems.stackSize, Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) + 0.01 ); this.itemToSend -= newItems.stackSize; if ( this.lastItemChecked == null || !this.lastItemChecked.isSameType( newItems ) ) @@ -269,7 +263,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin else this.lastItemChecked.setStackSize( newItems.stackSize ); - IAEItemStack failed = Platform.poweredInsert( energy, this.destination, this.lastItemChecked, this.mySrc ); + IAEItemStack failed = Platform.poweredInsert( energy, this.destination, this.lastItemChecked, this.source ); // destination.injectItems( lastItemChecked, Actionable.MODULATE ); if ( failed != null ) { @@ -285,10 +279,16 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin return false; } + private IInventoryDestination configDestination( IMEMonitor itemInventory ) + { + this.destination = itemInventory; + return this; + } + @Override public RedstoneMode getRSMode() { - return (RedstoneMode) this.settings.getSetting( Settings.REDSTONE_CONTROLLED ); + return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ); } @Override @@ -296,5 +296,4 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin { return this.getHandler() == null || super.isSleeping(); } - } diff --git a/src/main/java/appeng/parts/automation/PartLevelEmitter.java b/src/main/java/appeng/parts/automation/PartLevelEmitter.java index c97677c0f..bd3cd8532 100644 --- a/src/main/java/appeng/parts/automation/PartLevelEmitter.java +++ b/src/main/java/appeng/parts/automation/PartLevelEmitter.java @@ -73,14 +73,15 @@ import appeng.api.util.AECableType; import appeng.api.util.IConfigManager; import appeng.client.texture.CableBusTextures; import appeng.core.sync.GuiBridge; +import appeng.helpers.Reflected; import appeng.me.GridAccessException; import appeng.tile.inventory.AppEngInternalAEInventory; import appeng.tile.inventory.InvOperation; import appeng.util.Platform; -public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherHost, IStackWatcherHost, ICraftingWatcherHost, - IMEMonitorHandlerReceiver, ICraftingProvider +public class PartLevelEmitter extends PartUpgradeable + implements IEnergyWatcherHost, IStackWatcherHost, ICraftingWatcherHost, IMEMonitorHandlerReceiver, ICraftingProvider { final int FLAG_ON = 4; @@ -95,6 +96,21 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH IStackWatcher myWatcher; IEnergyWatcher myEnergyWatcher; ICraftingWatcher myCraftingWatcher; + double centerX; + double centerY; + double centerZ; + boolean status = false; + + @Reflected + public PartLevelEmitter( ItemStack is ) + { + super( is ); + + this.getConfigManager().registerSetting( Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL ); + this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); + this.getConfigManager().registerSetting( Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL ); + this.getConfigManager().registerSetting( Settings.CRAFT_VIA_REDSTONE, YesNo.NO ); + } public long getReportingValue() { @@ -116,24 +132,6 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH this.updateState(); } - @MENetworkEventSubscribe - public void channelChanged( MENetworkChannelsChanged c ) - { - this.updateState(); - } - - @Override - public void upgradesChanged() - { - this.configureWatchers(); - } - - @Override - public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue ) - { - this.configureWatchers(); - } - private void updateState() { boolean isOn = this.isLevelEmitterOn(); @@ -147,24 +145,40 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH } } - @Override - public void writeToNBT( NBTTagCompound data ) + private boolean isLevelEmitterOn() { - super.writeToNBT( data ); - data.setLong( "lastReportedValue", this.lastReportedValue ); - data.setLong( "reportingValue", this.reportingValue ); - data.setBoolean( "prevState", this.prevState ); - this.config.writeToNBT( data, "config" ); + if ( Platform.isClient() ) + { + return ( this.clientFlags & this.FLAG_ON ) == this.FLAG_ON; + } + + if ( !this.proxy.isActive() ) + { + return false; + } + + if ( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 ) + { + try + { + return this.proxy.getCrafting().isRequesting( this.config.getAEStackInSlot( 0 ) ); + } + catch ( GridAccessException e ) + { + // :P + } + + return this.prevState; + } + + boolean flipState = this.getConfigManager().getSetting( Settings.REDSTONE_EMITTER ) == RedstoneMode.LOW_SIGNAL; + return flipState ? this.reportingValue >= this.lastReportedValue + 1 : this.reportingValue < this.lastReportedValue + 1; } - @Override - public void readFromNBT( NBTTagCompound data ) + @MENetworkEventSubscribe + public void channelChanged( MENetworkChannelsChanged c ) { - super.readFromNBT( data ); - this.lastReportedValue = data.getLong( "lastReportedValue" ); - this.reportingValue = data.getLong( "reportingValue" ); - this.prevState = data.getBoolean( "prevState" ); - this.config.readFromNBT( data, "config" ); + this.updateState(); } @Override @@ -173,6 +187,12 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH return cf | ( this.prevState ? this.FLAG_ON : 0 ); } + @Override + public IIcon getBreakingTexture() + { + return this.is.getIconIndex(); + } + @Override public void updateWatcher( ICraftingWatcher newWatcher ) { @@ -181,18 +201,11 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH } @Override - public void updateWatcher( IStackWatcher newWatcher ) + public void onRequestChange( ICraftingGrid craftingGrid, IAEItemStack what ) { - this.myWatcher = newWatcher; - this.configureWatchers(); + this.updateState(); } - @Override - public void updateWatcher( IEnergyWatcher newWatcher ) - { - this.myEnergyWatcher = newWatcher; - this.configureWatchers(); - } // update the system... public void configureWatchers() @@ -228,12 +241,12 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH if ( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL ) { if ( this.myEnergyWatcher != null ) - this.myEnergyWatcher.add( ( double ) this.reportingValue ); + this.myEnergyWatcher.add( (double) this.reportingValue ); try { // update to power... - this.lastReportedValue = ( long ) this.proxy.getEnergy().getStoredPower(); + this.lastReportedValue = (long) this.proxy.getEnergy().getStoredPower(); this.updateState(); // no more item stuff.. @@ -269,35 +282,6 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH } } - @Override - public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack ) - { - if ( inv == this.config ) - this.configureWatchers(); - - super.onChangeInventory( inv, slot, mc, removedStack, newStack ); - } - - @Override - public void postChange( IBaseMonitor monitor, Iterable change, BaseActionSource actionSource ) - { - this.updateReportingValue( ( IMEMonitor ) monitor ); - } - - @Override - public boolean onPartActivate( EntityPlayer player, Vec3 pos ) - { - if ( !player.isSneaking() ) - { - if ( Platform.isClient() ) - return true; - - Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_LEVEL_EMITTER ); - return true; - } - - return false; - } private void updateReportingValue( IMEMonitor monitor ) { @@ -312,7 +296,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH else if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) { this.lastReportedValue = 0; - FuzzyMode fzMode = ( FuzzyMode ) this.getConfigManager().getSetting( Settings.FUZZY_MODE ); + FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ); Collection fuzzyList = monitor.getStorageList().findFuzzy( myStack, fzMode ); for ( IAEItemStack st : fuzzyList ) this.lastReportedValue += st.getStackSize(); @@ -329,6 +313,42 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH this.updateState(); } + + @Override + public void updateWatcher( IStackWatcher newWatcher ) + { + this.myWatcher = newWatcher; + this.configureWatchers(); + } + + + @Override + public void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan ) + { + if ( chan == StorageChannel.ITEMS && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this.getInstalledUpgrades( Upgrades.FUZZY ) == 0 ) + { + this.lastReportedValue = fullStack.getStackSize(); + this.updateState(); + } + } + + + @Override + public void updateWatcher( IEnergyWatcher newWatcher ) + { + this.myEnergyWatcher = newWatcher; + this.configureWatchers(); + } + + + @Override + public void onThresholdPass( IEnergyGrid energyGrid ) + { + this.lastReportedValue = (long) energyGrid.getStoredPower(); + this.updateState(); + } + + @Override public boolean isValid( Object effectiveGrid ) { @@ -342,37 +362,27 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH } } - @Override - public void onRequestChange( ICraftingGrid craftingGrid, IAEItemStack what ) - { - this.updateState(); - } @Override - public void onThresholdPass( IEnergyGrid energyGrid ) + public void postChange( IBaseMonitor monitor, Iterable change, BaseActionSource actionSource ) { - this.lastReportedValue = ( long ) energyGrid.getStoredPower(); - this.updateState(); + this.updateReportingValue( (IMEMonitor) monitor ); } + @Override - public void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan ) + public void onListUpdate() { - if ( chan == StorageChannel.ITEMS && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this.getInstalledUpgrades( Upgrades.FUZZY ) == 0 ) + try { - this.lastReportedValue = fullStack.getStackSize(); - this.updateState(); + this.updateReportingValue( this.proxy.getStorage().getItemInventory() ); + } + catch ( GridAccessException e ) + { + // ;P } } - public PartLevelEmitter( ItemStack is ) - { - super( PartLevelEmitter.class, is ); - this.getConfigManager().registerSetting( Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL ); - this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); - this.getConfigManager().registerSetting( Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL ); - this.getConfigManager().registerSetting( Settings.CRAFT_VIA_REDSTONE, YesNo.NO ); - } @Override @SideOnly( Side.CLIENT ) @@ -386,75 +396,6 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH // rh.renderInventoryBox( renderer ); } - double centerX; - double centerY; - double centerZ; - - public void addVertexWithUV( double x, double y, double z, double u, double v ) - { - Tessellator var12 = Tessellator.instance; - - x -= this.centerX; - y -= this.centerY; - z -= this.centerZ; - - if ( this.side == ForgeDirection.DOWN ) - { - y = -y; - z = -z; - } - - if ( this.side == ForgeDirection.EAST ) - { - double m = x; - x = y; - y = m; - y = -y; - } - - if ( this.side == ForgeDirection.WEST ) - { - double m = x; - x = -y; - y = m; - } - - if ( this.side == ForgeDirection.SOUTH ) - { - double m = z; - z = y; - y = m; - y = -y; - } - - if ( this.side == ForgeDirection.NORTH ) - { - double m = z; - z = -y; - y = m; - } - - x += this.centerX;// + orientation.offsetX * 0.4; - y += this.centerY;// + orientation.offsetY * 0.4; - z += this.centerZ;// + orientation.offsetZ * 0.4; - - var12.addVertexWithUV( x, y, z, u, v ); - } - - @Override - public void randomDisplayTick( World world, int x, int y, int z, Random r ) - { - if ( this.isLevelEmitterOn() ) - { - ForgeDirection d = this.side; - - double d0 = d.offsetX * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D; - double d1 = d.offsetY * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D; - double d2 = d.offsetZ * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D; - - world.spawnParticle( "reddust", 0.5 + x + d0, 0.5 + y + d1, 0.5 + z + d2, 0.0D, 0.0D, 0.0D ); - } - } public void renderTorchAtAngle( double baseX, double baseY, double baseZ ) { @@ -564,38 +505,59 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH this.addVertexWithUV( var36, baseY + 1.0D, baseZ - var44, var17, var18 ); } - boolean status = false; - private boolean isLevelEmitterOn() + public void addVertexWithUV( double x, double y, double z, double u, double v ) { - if ( Platform.isClient() ) + Tessellator var12 = Tessellator.instance; + + x -= this.centerX; + y -= this.centerY; + z -= this.centerZ; + + if ( this.side == ForgeDirection.DOWN ) { - return ( this.clientFlags & this.FLAG_ON ) == this.FLAG_ON; + y = -y; + z = -z; } - if ( !this.proxy.isActive() ) + if ( this.side == ForgeDirection.EAST ) { - return false; + double m = x; + x = y; + y = m; + y = -y; } - if ( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 ) + if ( this.side == ForgeDirection.WEST ) { - try - { - return this.proxy.getCrafting().isRequesting( this.config.getAEStackInSlot( 0 ) ); - } - catch ( GridAccessException e ) - { - // :P - } - - return this.prevState; + double m = x; + x = -y; + y = m; } - boolean flipState = this.getConfigManager().getSetting( Settings.REDSTONE_EMITTER ) == RedstoneMode.LOW_SIGNAL; - return flipState ? this.reportingValue >= this.lastReportedValue + 1 : this.reportingValue < this.lastReportedValue + 1; + if ( this.side == ForgeDirection.SOUTH ) + { + double m = z; + z = y; + y = m; + y = -y; + } + + if ( this.side == ForgeDirection.NORTH ) + { + double m = z; + z = -y; + y = m; + } + + x += this.centerX;// + orientation.offsetX * 0.4; + y += this.centerY;// + orientation.offsetY * 0.4; + z += this.centerZ;// + orientation.offsetZ * 0.4; + + var12.addVertexWithUV( x, y, z, u, v ); } + @Override @SideOnly( Side.CLIENT ) public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ) @@ -625,35 +587,6 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH // super.renderWorldBlock( world, x, y, z, block, modelId, renderer ); } - @Override - public IIcon getBreakingTexture() - { - return this.is.getIconIndex(); - } - - @Override - public void getBoxes( IPartCollisionHelper bch ) - { - bch.addBox( 7, 7, 11, 9, 9, 16 ); - } - - @Override - public AECableType getCableConnectionType( ForgeDirection dir ) - { - return AECableType.SMART; - } - - @Override - public int cableConnectionRenderTo() - { - return 16; - } - - @Override - public boolean canConnectRedstone() - { - return true; - } @Override public int isProvidingStrongPower() @@ -661,12 +594,96 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH return this.prevState ? 15 : 0; } + @Override public int isProvidingWeakPower() { return this.prevState ? 15 : 0; } + + @Override + public void getBoxes( IPartCollisionHelper bch ) + { + bch.addBox( 7, 7, 11, 9, 9, 16 ); + } + + + @Override + public void randomDisplayTick( World world, int x, int y, int z, Random r ) + { + if ( this.isLevelEmitterOn() ) + { + ForgeDirection d = this.side; + + double d0 = d.offsetX * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D; + double d1 = d.offsetY * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D; + double d2 = d.offsetZ * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D; + + world.spawnParticle( "reddust", 0.5 + x + d0, 0.5 + y + d1, 0.5 + z + d2, 0.0D, 0.0D, 0.0D ); + } + } + + + @Override + public AECableType getCableConnectionType( ForgeDirection dir ) + { + return AECableType.SMART; + } + + + @Override + public int cableConnectionRenderTo() + { + return 16; + } + + + @Override + public boolean onPartActivate( EntityPlayer player, Vec3 pos ) + { + if ( !player.isSneaking() ) + { + if ( Platform.isClient() ) + return true; + + Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_LEVEL_EMITTER ); + return true; + } + + return false; + } + + + @Override + public boolean canConnectRedstone() + { + return true; + } + + + @Override + public void writeToNBT( NBTTagCompound data ) + { + super.writeToNBT( data ); + data.setLong( "lastReportedValue", this.lastReportedValue ); + data.setLong( "reportingValue", this.reportingValue ); + data.setBoolean( "prevState", this.prevState ); + this.config.writeToNBT( data, "config" ); + } + + + @Override + public void readFromNBT( NBTTagCompound data ) + { + super.readFromNBT( data ); + this.lastReportedValue = data.getLong( "lastReportedValue" ); + this.reportingValue = data.getLong( "reportingValue" ); + this.prevState = data.getBoolean( "prevState" ); + this.config.readFromNBT( data, "config" ); + } + + @Override public IInventory getInventoryByName( String name ) { @@ -676,17 +693,28 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH return super.getInventoryByName( name ); } + @Override - public void onListUpdate() + public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue ) { - try - { - this.updateReportingValue( this.proxy.getStorage().getItemInventory() ); - } - catch ( GridAccessException e ) - { - // ;P - } + this.configureWatchers(); + } + + + @Override + public void upgradesChanged() + { + this.configureWatchers(); + } + + + @Override + public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack ) + { + if ( inv == this.config ) + this.configureWatchers(); + + super.onChangeInventory( inv, slot, mc, removedStack, newStack ); } @Override @@ -706,7 +734,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH { if ( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 ) { - if ( this.settings.getSetting( Settings.CRAFT_VIA_REDSTONE ) == YesNo.YES ) + if ( this.getConfigManager().getSetting( Settings.CRAFT_VIA_REDSTONE ) == YesNo.YES ) { IAEItemStack what = this.config.getAEStackInSlot( 0 ); if ( what != null ) diff --git a/src/main/java/appeng/parts/automation/PartSharedItemBus.java b/src/main/java/appeng/parts/automation/PartSharedItemBus.java index 8b55f1a42..e5f7884eb 100644 --- a/src/main/java/appeng/parts/automation/PartSharedItemBus.java +++ b/src/main/java/appeng/parts/automation/PartSharedItemBus.java @@ -18,6 +18,7 @@ package appeng.parts.automation; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -32,29 +33,18 @@ import appeng.tile.inventory.AppEngInternalAEInventory; import appeng.util.InventoryAdaptor; import appeng.util.Platform; + public abstract class PartSharedItemBus extends PartUpgradeable implements IGridTickable { - private TileEntity getTileEntity(TileEntity self, int x, int y, int z) + final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 9 ); + int adaptorHash = 0; + InventoryAdaptor adaptor; + boolean lastRedstone = false; + + public PartSharedItemBus( ItemStack is ) { - World w = self.getWorldObj(); - - if ( w.getChunkProvider().chunkExists( x >> 4, z >> 4 ) ) - { - return w.getTileEntity( x, y, z ); - } - - return null; - } - - public PartSharedItemBus(Class c, ItemStack is) { - super( c, is ); - } - - @Override - public void upgradesChanged() - { - this.updateState(); + super( is ); } protected int availableSlots() @@ -63,23 +53,48 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid } @Override - public void writeToNBT(net.minecraft.nbt.NBTTagCompound extra) + public void writeToNBT( net.minecraft.nbt.NBTTagCompound extra ) { super.writeToNBT( extra ); this.config.writeToNBT( extra, "config" ); } @Override - public void readFromNBT(net.minecraft.nbt.NBTTagCompound extra) + public void readFromNBT( net.minecraft.nbt.NBTTagCompound extra ) { super.readFromNBT( extra ); this.config.readFromNBT( extra, "config" ); } - final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 9 ); + @Override + public IInventory getInventoryByName( String name ) + { + if ( name.equals( "config" ) ) + return this.config; - int adaptorHash = 0; - InventoryAdaptor adaptor; + return super.getInventoryByName( name ); + } + + @Override + public void upgradesChanged() + { + this.updateState(); + } + + private void updateState() + { + try + { + if ( !this.isSleeping() ) + this.proxy.getTick().wakeDevice( this.proxy.getNode() ); + else + this.proxy.getTick().sleepDevice( this.proxy.getNode() ); + } + catch ( GridAccessException e ) + { + // :P + } + } InventoryAdaptor getHandler() { @@ -97,9 +112,17 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid return this.adaptor; } - boolean lastRedstone = false; + private TileEntity getTileEntity( TileEntity self, int x, int y, int z ) + { + World w = self.getWorldObj(); - abstract TickRateModulation doBusWork(); + if ( w.getChunkProvider().chunkExists( x >> 4, z >> 4 ) ) + { + return w.getTileEntity( x, y, z ); + } + + return null; + } @Override public void onNeighborChanged() @@ -113,28 +136,5 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid } } - private void updateState() - { - try - { - if ( !this.isSleeping() ) - this.proxy.getTick().wakeDevice( this.proxy.getNode() ); - else - this.proxy.getTick().sleepDevice( this.proxy.getNode() ); - } - catch (GridAccessException e) - { - // :P - } - } - - @Override - public IInventory getInventoryByName(String name) - { - if ( name.equals( "config" ) ) - return this.config; - - return super.getInventoryByName( name ); - } - + abstract TickRateModulation doBusWork(); } diff --git a/src/main/java/appeng/parts/automation/PartUpgradeable.java b/src/main/java/appeng/parts/automation/PartUpgradeable.java index 5779e3545..df1ca3568 100644 --- a/src/main/java/appeng/parts/automation/PartUpgradeable.java +++ b/src/main/java/appeng/parts/automation/PartUpgradeable.java @@ -18,6 +18,7 @@ package appeng.parts.automation; + import java.util.List; import net.minecraft.inventory.IInventory; @@ -32,22 +33,18 @@ import appeng.tile.inventory.InvOperation; import appeng.util.ConfigManager; import appeng.util.IConfigManagerHost; -public class PartUpgradeable extends PartBasicState implements IAEAppEngInventory, IConfigManagerHost + +public abstract class PartUpgradeable extends PartBasicState implements IAEAppEngInventory, IConfigManagerHost { + private final IConfigManager manager; + private final UpgradeInventory upgrades; - final IConfigManager settings = new ConfigManager( this ); - private final UpgradeInventory upgrades = new UpgradeInventory( this.is, this, this.getUpgradeSlots() ); - - @Override - public int getInstalledUpgrades(Upgrades u) + public PartUpgradeable( ItemStack is ) { - return this.upgrades.getInstalledUpgrades( u ); - } - - @Override - public boolean canConnectRedstone() - { - return this.upgrades.getMaxInstalled( Upgrades.REDSTONE ) > 0; + super( is ); + this.upgrades = new StackUpgradeInventory( this.is, this, this.getUpgradeSlots() ); + this.upgrades.setMaxStackSize( 1 ); + this.manager = new ConfigManager( this ); } protected int getUpgradeSlots() @@ -56,42 +53,43 @@ public class PartUpgradeable extends PartBasicState implements IAEAppEngInventor } @Override - public void getDrops(List drops, boolean wrenched) + public boolean canConnectRedstone() { - for (ItemStack is : this.upgrades) + return this.upgrades.getMaxInstalled( Upgrades.REDSTONE ) > 0; + } + + @Override + public void readFromNBT( net.minecraft.nbt.NBTTagCompound extra ) + { + super.readFromNBT( extra ); + this.manager.readFromNBT( extra ); + this.upgrades.readFromNBT( extra, "upgrades" ); + } + + @Override + public void writeToNBT( net.minecraft.nbt.NBTTagCompound extra ) + { + super.writeToNBT( extra ); + this.manager.writeToNBT( extra ); + this.upgrades.writeToNBT( extra, "upgrades" ); + } + + @Override + public void getDrops( List drops, boolean wrenched ) + { + for ( ItemStack is : this.upgrades ) if ( is != null ) drops.add( is ); } - @Override - public void writeToNBT(net.minecraft.nbt.NBTTagCompound extra) - { - super.writeToNBT( extra ); - this.settings.writeToNBT( extra ); - this.upgrades.writeToNBT( extra, "upgrades" ); - } - - @Override - public void readFromNBT(net.minecraft.nbt.NBTTagCompound extra) - { - super.readFromNBT( extra ); - this.settings.readFromNBT( extra ); - this.upgrades.readFromNBT( extra, "upgrades" ); - } - - public PartUpgradeable(Class c, ItemStack is) { - super( c, is ); - this.upgrades.setMaxStackSize( 1 ); - } - @Override public IConfigManager getConfigManager() { - return this.settings; + return this.manager; } @Override - public IInventory getInventoryByName(String name) + public IInventory getInventoryByName( String name ) { if ( name.equals( "upgrades" ) ) return this.upgrades; @@ -100,18 +98,19 @@ public class PartUpgradeable extends PartBasicState implements IAEAppEngInventor } @Override - public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue) + public int getInstalledUpgrades( Upgrades u ) { - + return this.upgrades.getInstalledUpgrades( u ); } - public void upgradesChanged() + @Override + public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue ) { } @Override - public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) + public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack ) { if ( inv == this.upgrades ) { @@ -119,36 +118,35 @@ public class PartUpgradeable extends PartBasicState implements IAEAppEngInventor } } - public RedstoneMode getRSMode() + public void upgradesChanged() { - return null; + } protected boolean isSleeping() { if ( this.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 ) { - switch (this.getRSMode()) + switch ( this.getRSMode() ) { - case IGNORE: - return false; - - case HIGH_SIGNAL: - if ( this.host.hasRedstone( this.side ) ) + case IGNORE: return false; - break; + case HIGH_SIGNAL: + if ( this.host.hasRedstone( this.side ) ) + return false; - case LOW_SIGNAL: - if ( !this.host.hasRedstone( this.side ) ) - return false; + break; - break; + case LOW_SIGNAL: + if ( !this.host.hasRedstone( this.side ) ) + return false; - case SIGNAL_PULSE: - default: - break; + break; + case SIGNAL_PULSE: + default: + break; } return true; @@ -156,4 +154,9 @@ public class PartUpgradeable extends PartBasicState implements IAEAppEngInventor return false; } + + public RedstoneMode getRSMode() + { + return null; + } } diff --git a/src/main/java/appeng/parts/automation/StackUpgradeInventory.java b/src/main/java/appeng/parts/automation/StackUpgradeInventory.java new file mode 100644 index 000000000..5cdd0cbba --- /dev/null +++ b/src/main/java/appeng/parts/automation/StackUpgradeInventory.java @@ -0,0 +1,37 @@ +package appeng.parts.automation; + + +import net.minecraft.item.ItemStack; + +import appeng.api.config.Upgrades; +import appeng.tile.inventory.IAEAppEngInventory; +import appeng.util.Platform; + + +public class StackUpgradeInventory extends UpgradeInventory +{ + private final ItemStack stack; + + public StackUpgradeInventory( ItemStack stack, IAEAppEngInventory inventory, int s ) + { + super( inventory, s ); + this.stack = stack; + } + + + public int getMaxInstalled( Upgrades upgrades ) + { + int max = 0; + + for ( ItemStack is : upgrades.getSupported().keySet() ) + { + if ( Platform.isSameItem( this.stack, is ) ) + { + max = upgrades.getSupported().get( is ); + break; + } + } + + return max; + } +} diff --git a/src/main/java/appeng/parts/automation/UpgradeInventory.java b/src/main/java/appeng/parts/automation/UpgradeInventory.java index c6bf6dc91..793fc4f25 100644 --- a/src/main/java/appeng/parts/automation/UpgradeInventory.java +++ b/src/main/java/appeng/parts/automation/UpgradeInventory.java @@ -18,10 +18,9 @@ package appeng.parts.automation; -import net.minecraft.block.Block; + import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -32,25 +31,24 @@ import appeng.tile.inventory.IAEAppEngInventory; import appeng.tile.inventory.InvOperation; import appeng.util.Platform; -public class UpgradeInventory extends AppEngInternalInventory implements IAEAppEngInventory -{ - private final Object itemOrBlock; +public abstract class UpgradeInventory extends AppEngInternalInventory implements IAEAppEngInventory +{ private final IAEAppEngInventory parent; private boolean cached = false; - private int FuzzyUpgrades = 0; - private int SpeedUpgrades = 0; - private int RedstoneUpgrades = 0; - private int CapacityUpgrades = 0; - private int InverterUpgrades = 0; - private int CraftingUpgrades = 0; + private int fuzzyUpgrades = 0; + private int speedUpgrades = 0; + private int redstoneUpgrades = 0; + private int capacityUpgrades = 0; + private int inverterUpgrades = 0; + private int craftingUpgrades = 0; - public UpgradeInventory(Object itemOrBlock, IAEAppEngInventory _te, int s) { + public UpgradeInventory( IAEAppEngInventory parent, int s ) + { super( null, s ); this.te = this; - this.parent = _te; - this.itemOrBlock = itemOrBlock; + this.parent = parent; } @Override @@ -60,14 +58,20 @@ public class UpgradeInventory extends AppEngInternalInventory implements IAEAppE } @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) + public int getInventoryStackLimit() + { + return 1; + } + + @Override + public boolean isItemValidForSlot( int i, ItemStack itemstack ) { if ( itemstack == null ) return false; Item it = itemstack.getItem(); if ( it instanceof IUpgradeModule ) { - Upgrades u = ((IUpgradeModule) it).getType( itemstack ); + Upgrades u = ( (IUpgradeModule) it ).getType( itemstack ); if ( u != null ) { return this.getInstalledUpgrades( u ) < this.getMaxInstalled( u ); @@ -76,120 +80,81 @@ public class UpgradeInventory extends AppEngInternalInventory implements IAEAppE return false; } - public int getMaxInstalled(Upgrades u) - { - Integer max = null; - for (ItemStack is : u.getSupported().keySet()) - { - if ( is.getItem() == this.itemOrBlock ) - { - max = u.getSupported().get( is ); - break; - } - else if ( is.getItem() instanceof ItemBlock && Block.getBlockFromItem( is.getItem() ) == this.itemOrBlock ) - { - max = u.getSupported().get( is ); - break; - } - else if ( this.itemOrBlock instanceof ItemStack && Platform.isSameItem( (ItemStack) this.itemOrBlock, is ) ) - { - max = u.getSupported().get( is ); - break; - } - } - - if ( max == null ) - return 0; - return max; - } - - @Override - public int getInventoryStackLimit() - { - return 1; - } - - private void updateUpgradeInfo() - { - this.cached = true; - this.InverterUpgrades = this.CapacityUpgrades = this.RedstoneUpgrades = this.SpeedUpgrades = this.FuzzyUpgrades = this.CraftingUpgrades = 0; - - for (ItemStack is : this) - { - if ( is == null || is.getItem() == null || !(is.getItem() instanceof IUpgradeModule) ) - continue; - - Upgrades myUpgrade = ((IUpgradeModule) is.getItem()).getType( is ); - switch (myUpgrade) - { - case CAPACITY: - this.CapacityUpgrades++; - break; - case FUZZY: - this.FuzzyUpgrades++; - break; - case REDSTONE: - this.RedstoneUpgrades++; - break; - case SPEED: - this.SpeedUpgrades++; - break; - case INVERTER: - this.InverterUpgrades++; - break; - case CRAFTING: - this.CraftingUpgrades++; - break; - default: - break; - } - } - - this.CapacityUpgrades = Math.min( this.CapacityUpgrades, this.getMaxInstalled( Upgrades.CAPACITY ) ); - this.FuzzyUpgrades = Math.min( this.FuzzyUpgrades, this.getMaxInstalled( Upgrades.FUZZY ) ); - this.RedstoneUpgrades = Math.min( this.RedstoneUpgrades, this.getMaxInstalled( Upgrades.REDSTONE ) ); - this.SpeedUpgrades = Math.min( this.SpeedUpgrades, this.getMaxInstalled( Upgrades.SPEED ) ); - this.InverterUpgrades = Math.min( this.InverterUpgrades, this.getMaxInstalled( Upgrades.INVERTER ) ); - this.CraftingUpgrades = Math.min( this.CraftingUpgrades, this.getMaxInstalled( Upgrades.CRAFTING ) ); - } - - public int getInstalledUpgrades(Upgrades u) + public int getInstalledUpgrades( Upgrades u ) { if ( !this.cached ) this.updateUpgradeInfo(); - switch (u) + switch ( u ) { - case CAPACITY: - return this.CapacityUpgrades; - case FUZZY: - return this.FuzzyUpgrades; - case REDSTONE: - return this.RedstoneUpgrades; - case SPEED: - return this.SpeedUpgrades; - case INVERTER: - return this.InverterUpgrades; - case CRAFTING: - return this.CraftingUpgrades; - default: - return 0; + case CAPACITY: + return this.capacityUpgrades; + case FUZZY: + return this.fuzzyUpgrades; + case REDSTONE: + return this.redstoneUpgrades; + case SPEED: + return this.speedUpgrades; + case INVERTER: + return this.inverterUpgrades; + case CRAFTING: + return this.craftingUpgrades; + default: + return 0; } } - @Override - public void readFromNBT(NBTTagCompound target) + public abstract int getMaxInstalled( Upgrades upgrades ); + + private void updateUpgradeInfo() { - super.readFromNBT( target ); - this.updateUpgradeInfo(); + this.cached = true; + this.inverterUpgrades = this.capacityUpgrades = this.redstoneUpgrades = this.speedUpgrades = this.fuzzyUpgrades = this.craftingUpgrades = 0; + + for ( ItemStack is : this ) + { + if ( is == null || is.getItem() == null || !( is.getItem() instanceof IUpgradeModule ) ) + continue; + + Upgrades myUpgrade = ( (IUpgradeModule) is.getItem() ).getType( is ); + switch ( myUpgrade ) + { + case CAPACITY: + this.capacityUpgrades++; + break; + case FUZZY: + this.fuzzyUpgrades++; + break; + case REDSTONE: + this.redstoneUpgrades++; + break; + case SPEED: + this.speedUpgrades++; + break; + case INVERTER: + this.inverterUpgrades++; + break; + case CRAFTING: + this.craftingUpgrades++; + break; + default: + break; + } + } + + this.capacityUpgrades = Math.min( this.capacityUpgrades, this.getMaxInstalled( Upgrades.CAPACITY ) ); + this.fuzzyUpgrades = Math.min( this.fuzzyUpgrades, this.getMaxInstalled( Upgrades.FUZZY ) ); + this.redstoneUpgrades = Math.min( this.redstoneUpgrades, this.getMaxInstalled( Upgrades.REDSTONE ) ); + this.speedUpgrades = Math.min( this.speedUpgrades, this.getMaxInstalled( Upgrades.SPEED ) ); + this.inverterUpgrades = Math.min( this.inverterUpgrades, this.getMaxInstalled( Upgrades.INVERTER ) ); + this.craftingUpgrades = Math.min( this.craftingUpgrades, this.getMaxInstalled( Upgrades.CRAFTING ) ); } @Override - public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) + public void readFromNBT( NBTTagCompound target ) { - this.cached = false; - if ( this.parent != null && Platform.isServer() ) - this.parent.onChangeInventory( inv, slot, mc, removedStack, newStack ); + super.readFromNBT( target ); + this.updateUpgradeInfo(); } @Override @@ -198,4 +163,11 @@ public class UpgradeInventory extends AppEngInternalInventory implements IAEAppE this.parent.saveChanges(); } + @Override + public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack ) + { + this.cached = false; + if ( this.parent != null && Platform.isServer() ) + this.parent.onChangeInventory( inv, slot, mc, removedStack, newStack ); + } } diff --git a/src/main/java/appeng/parts/misc/PartInterface.java b/src/main/java/appeng/parts/misc/PartInterface.java index ae860af09..48af72277 100644 --- a/src/main/java/appeng/parts/misc/PartInterface.java +++ b/src/main/java/appeng/parts/misc/PartInterface.java @@ -18,11 +18,10 @@ package appeng.parts.misc; + import java.util.EnumSet; import java.util.List; -import com.google.common.collect.ImmutableSet; - import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -38,6 +37,8 @@ import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import com.google.common.collect.ImmutableSet; + import appeng.api.config.Actionable; import appeng.api.config.Upgrades; import appeng.api.implementations.tiles.ITileStorageMonitorable; @@ -64,73 +65,43 @@ import appeng.core.sync.GuiBridge; import appeng.helpers.DualityInterface; import appeng.helpers.IInterfaceHost; import appeng.helpers.IPriorityHost; +import appeng.helpers.Reflected; import appeng.parts.PartBasicState; import appeng.tile.inventory.IAEAppEngInventory; import appeng.tile.inventory.InvOperation; import appeng.util.Platform; import appeng.util.inv.IInventoryDestination; -public class PartInterface extends PartBasicState implements IGridTickable, IStorageMonitorable, IInventoryDestination, IInterfaceHost, - ISidedInventory, IAEAppEngInventory, ITileStorageMonitorable, IPriorityHost + +public class PartInterface extends PartBasicState + implements IGridTickable, IStorageMonitorable, IInventoryDestination, IInterfaceHost, ISidedInventory, IAEAppEngInventory, ITileStorageMonitorable, IPriorityHost { final DualityInterface duality = new DualityInterface( this.proxy, this ); - public PartInterface(ItemStack is) { - super( PartInterface.class, is ); - } - - @Override - public void addToWorld() + @Reflected + public PartInterface( ItemStack is ) { - super.addToWorld(); - this.duality.initialize(); + super( is ); } @MENetworkEventSubscribe - public void stateChange(MENetworkChannelsChanged c) + public void stateChange( MENetworkChannelsChanged c ) { this.duality.notifyNeighbors(); } @MENetworkEventSubscribe - public void stateChange(MENetworkPowerStatusChange c) + public void stateChange( MENetworkPowerStatusChange c ) { this.duality.notifyNeighbors(); } @Override - public void gridChanged() + @SideOnly( Side.CLIENT ) + public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ) { - this.duality.gridChanged(); - } - - @Override - public void writeToNBT(NBTTagCompound data) - { - super.writeToNBT( data ); - this.duality.writeToNBT( data ); - } - - @Override - public void readFromNBT(NBTTagCompound data) - { - super.readFromNBT( data ); - this.duality.readFromNBT( data ); - } - - @Override - public void getDrops(List drops, boolean wrenched) - { - this.duality.addDrops( drops ); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) - { - rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), - this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); + rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); rh.setBounds( 3, 3, 15, 13, 13, 16 ); rh.renderInventoryBox( renderer ); @@ -143,25 +114,21 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto } @Override - @SideOnly(Side.CLIENT) - public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer) + @SideOnly( Side.CLIENT ) + public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ) { this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); - rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), - this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); + rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); rh.setBounds( 2, 2, 14, 14, 14, 16 ); rh.renderBlock( x, y, z, renderer ); - rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), - this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); + rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); rh.setBounds( 5, 5, 12, 11, 11, 13 ); rh.renderBlock( x, y, z, renderer ); - rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), - CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), - CableBusTextures.PartMonitorSidesStatus.getIcon() ); + rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() ); rh.setBounds( 5, 5, 13, 11, 11, 14 ); rh.renderBlock( x, y, z, renderer ); @@ -170,18 +137,39 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto } @Override - public IIcon getBreakingTexture() + public void readFromNBT( NBTTagCompound data ) { - return this.is.getIconIndex(); + super.readFromNBT( data ); + this.duality.readFromNBT( data ); } @Override - public void getBoxes(IPartCollisionHelper bch) + public void writeToNBT( NBTTagCompound data ) + { + super.writeToNBT( data ); + this.duality.writeToNBT( data ); + } + + @Override + public void addToWorld() + { + super.addToWorld(); + this.duality.initialize(); + } + + @Override + public void getBoxes( IPartCollisionHelper bch ) { bch.addBox( 2, 2, 14, 14, 14, 16 ); bch.addBox( 5, 5, 12, 11, 11, 14 ); } + @Override + public void getDrops( List drops, boolean wrenched ) + { + this.duality.addDrops( drops ); + } + @Override public int cableConnectionRenderTo() { @@ -189,13 +177,49 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto } @Override - public TileEntity getTileEntity() + public void gridChanged() { - return super.getHost().getTile(); + this.duality.gridChanged(); } @Override - public boolean canInsert(ItemStack stack) + public IConfigManager getConfigManager() + { + return this.duality.getConfigManager(); + } + + @Override + public IInventory getInventoryByName( String name ) + { + return this.duality.getInventoryByName( name ); + } + + @Override + public int getInstalledUpgrades( Upgrades u ) + { + return this.duality.getInstalledUpgrades( u ); + } + + @Override + public boolean onPartActivate( EntityPlayer p, Vec3 pos ) + { + if ( p.isSneaking() ) + return false; + + if ( Platform.isServer() ) + Platform.openGUI( p, this.getTileEntity(), this.side, GuiBridge.GUI_INTERFACE ); + + return true; + } + + @Override + public IIcon getBreakingTexture() + { + return this.is.getIconIndex(); + } + + @Override + public boolean canInsert( ItemStack stack ) { return this.duality.canInsert( stack ); } @@ -213,13 +237,13 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto } @Override - public TickingRequest getTickingRequest(IGridNode node) + public TickingRequest getTickingRequest( IGridNode node ) { return this.duality.getTickingRequest( node ); } @Override - public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) + public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) { return this.duality.tickingRequest( node, TicksSinceLastCall ); } @@ -231,25 +255,25 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto } @Override - public ItemStack getStackInSlot(int i) + public ItemStack getStackInSlot( int i ) { return this.duality.getStorage().getStackInSlot( i ); } @Override - public ItemStack decrStackSize(int i, int j) + public ItemStack decrStackSize( int i, int j ) { return this.duality.getStorage().decrStackSize( i, j ); } @Override - public ItemStack getStackInSlotOnClosing(int i) + public ItemStack getStackInSlotOnClosing( int i ) { return this.duality.getStorage().getStackInSlotOnClosing( i ); } @Override - public void setInventorySlotContents(int i, ItemStack itemstack) + public void setInventorySlotContents( int i, ItemStack itemstack ) { this.duality.getStorage().setInventorySlotContents( i, itemstack ); } @@ -272,18 +296,6 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto return this.duality.getStorage().getInventoryStackLimit(); } - @Override - public IConfigManager getConfigManager() - { - return this.duality.getConfigManager(); - } - - @Override - public IInventory getInventoryByName(String name) - { - return this.duality.getInventoryByName( name ); - } - @Override public void markDirty() { @@ -291,7 +303,7 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto } @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) + public boolean isUseableByPlayer( EntityPlayer entityplayer ) { return this.duality.getStorage().isUseableByPlayer( entityplayer ); } @@ -309,31 +321,31 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto } @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) + public boolean isItemValidForSlot( int i, ItemStack itemstack ) { return this.duality.getStorage().isItemValidForSlot( i, itemstack ); } @Override - public int[] getAccessibleSlotsFromSide(int s) + public int[] getAccessibleSlotsFromSide( int s ) { return this.duality.getAccessibleSlotsFromSide( s ); } @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) + public boolean canInsertItem( int i, ItemStack itemstack, int j ) { return true; } @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) + public boolean canExtractItem( int i, ItemStack itemstack, int j ) { return true; } @Override - public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) + public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack ) { this.duality.onChangeInventory( inv, slot, mc, removedStack, newStack ); } @@ -345,41 +357,29 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto } @Override - public boolean onPartActivate(EntityPlayer p, Vec3 pos) + public EnumSet getTargets() { - if ( p.isSneaking() ) - return false; - - if ( Platform.isServer() ) - Platform.openGUI( p, this.getTileEntity(), this.side, GuiBridge.GUI_INTERFACE ); - - return true; + return EnumSet.of( this.side ); } @Override - public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src) + public TileEntity getTileEntity() + { + return super.getHost().getTile(); + } + + @Override + public IStorageMonitorable getMonitorable( ForgeDirection side, BaseActionSource src ) { return this.duality.getMonitorable( side, src, this ); } @Override - public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table) + public boolean pushPattern( ICraftingPatternDetails patternDetails, InventoryCrafting table ) { return this.duality.pushPattern( patternDetails, table ); } - @Override - public void provideCrafting(ICraftingProviderHelper craftingTracker) - { - this.duality.provideCrafting( craftingTracker ); - } - - @Override - public EnumSet getTargets() - { - return EnumSet.of( this.side ); - } - @Override public boolean isBusy() { @@ -387,9 +387,9 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto } @Override - public int getInstalledUpgrades(Upgrades u) + public void provideCrafting( ICraftingProviderHelper craftingTracker ) { - return this.duality.getInstalledUpgrades( u ); + this.duality.provideCrafting( craftingTracker ); } @Override @@ -399,13 +399,13 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto } @Override - public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) + public IAEItemStack injectCraftedItems( ICraftingLink link, IAEItemStack items, Actionable mode ) { return this.duality.injectCraftedItems( link, items, mode ); } @Override - public void jobStateChange(ICraftingLink link) + public void jobStateChange( ICraftingLink link ) { this.duality.jobStateChange( link ); } @@ -417,9 +417,8 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto } @Override - public void setPriority(int newValue) + public void setPriority( int newValue ) { this.duality.setPriority( newValue ); } - } diff --git a/src/main/java/appeng/parts/misc/PartInvertedToggleBus.java b/src/main/java/appeng/parts/misc/PartInvertedToggleBus.java index 3d95ce146..fbc3885da 100644 --- a/src/main/java/appeng/parts/misc/PartInvertedToggleBus.java +++ b/src/main/java/appeng/parts/misc/PartInvertedToggleBus.java @@ -18,13 +18,18 @@ package appeng.parts.misc; + import net.minecraft.item.ItemStack; +import appeng.helpers.Reflected; + + public class PartInvertedToggleBus extends PartToggleBus { - - public PartInvertedToggleBus(ItemStack is) { - super( PartInvertedToggleBus.class, is ); + @Reflected + public PartInvertedToggleBus( ItemStack is ) + { + super( is ); this.proxy.setIdlePowerUsage( 0.0 ); this.outerProxy.setIdlePowerUsage( 0.0 ); this.proxy.setFlags(); @@ -36,5 +41,4 @@ public class PartInvertedToggleBus extends PartToggleBus { return !super.getIntention(); } - } diff --git a/src/main/java/appeng/parts/misc/PartStorageBus.java b/src/main/java/appeng/parts/misc/PartStorageBus.java index 34127d81f..2e7c1efe4 100644 --- a/src/main/java/appeng/parts/misc/PartStorageBus.java +++ b/src/main/java/appeng/parts/misc/PartStorageBus.java @@ -76,6 +76,7 @@ import appeng.core.stats.Achievements; import appeng.core.sync.GuiBridge; import appeng.helpers.IInterfaceHost; import appeng.helpers.IPriorityHost; +import appeng.helpers.Reflected; import appeng.me.GridAccessException; import appeng.me.storage.MEInventoryHandler; import appeng.me.storage.MEMonitorIInventory; @@ -90,31 +91,29 @@ import appeng.util.prioitylist.PrecisePriorityList; @Interface( iname = "BC", iface = "buildcraft.api.transport.IPipeConnection" ) -public class PartStorageBus - extends PartUpgradeable +public class PartStorageBus extends PartUpgradeable implements IGridTickable, ICellContainer, IMEMonitorHandlerReceiver, IPipeConnection, IPriorityHost { - int priority = 0; final BaseActionSource mySrc; - final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 ); + int priority = 0; + boolean cached = false; + MEMonitorIInventory monitor = null; + MEInventoryHandler handler = null; + int handlerHash = 0; + boolean wasActive = false; + private byte resetCacheLogic = 0; + @Reflected public PartStorageBus( ItemStack is ) { - super( PartStorageBus.class, is ); + super( is ); this.getConfigManager().registerSetting( Settings.ACCESS, AccessRestriction.READ_WRITE ); this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); this.getConfigManager().registerSetting( Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY ); this.mySrc = new MachineSource( this ); } - boolean cached = false; - MEMonitorIInventory monitor = null; - MEInventoryHandler handler = null; - - int handlerHash = 0; - boolean wasActive = false; - @Override @MENetworkEventSubscribe public void powerRender( MENetworkPowerStatusChange c ) @@ -122,12 +121,6 @@ public class PartStorageBus this.updateStatus(); } - @MENetworkEventSubscribe - public void updateChannels( MENetworkChannelsChanged changedChannels ) - { - this.updateStatus(); - } - private void updateStatus() { boolean currentActive = this.proxy.isActive(); @@ -146,19 +139,10 @@ public class PartStorageBus } } - @Override - public boolean onPartActivate( EntityPlayer player, Vec3 pos ) + @MENetworkEventSubscribe + public void updateChannels( MENetworkChannelsChanged changedChannels ) { - if ( !player.isSneaking() ) - { - if ( Platform.isClient() ) - return true; - - Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_STORAGEBUS ); - return true; - } - - return false; + this.updateStatus(); } @Override @@ -168,9 +152,19 @@ public class PartStorageBus } @Override - public boolean isValid( Object verificationToken ) + public void writeToNBT( NBTTagCompound data ) { - return this.handler == verificationToken; + super.writeToNBT( data ); + this.Config.writeToNBT( data, "config" ); + data.setInteger( "priority", this.priority ); + } + + @Override + public void readFromNBT( NBTTagCompound data ) + { + super.readFromNBT( data ); + this.Config.readFromNBT( data, "config" ); + this.priority = data.getInteger( "priority" ); } @Override @@ -182,7 +176,102 @@ public class PartStorageBus return super.getInventoryByName( name ); } - private byte resetCacheLogic = 0; + @Override + public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue ) + { + this.resetCache( true ); + this.host.markForSave(); + } + + @Override + public void upgradesChanged() + { + super.upgradesChanged(); + this.resetCache( true ); + } + + @Override + public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack ) + { + super.onChangeInventory( inv, slot, mc, removedStack, newStack ); + + if ( inv == this.Config ) + this.resetCache( true ); + } + + @Override + public boolean isValid( Object verificationToken ) + { + return this.handler == verificationToken; + } + + @Override + public void postChange( IBaseMonitor monitor, Iterable change, BaseActionSource source ) + { + try + { + if ( this.proxy.isActive() ) + this.proxy.getStorage().postAlterationOfStoredItems( StorageChannel.ITEMS, change, this.mySrc ); + } + catch ( GridAccessException e ) + { + // :( + } + } + + @Override + public void onListUpdate() + { + // not used here. + } + + @Override + @SideOnly( Side.CLIENT ) + public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ) + { + rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() ); + + rh.setBounds( 3, 3, 15, 13, 13, 16 ); + rh.renderInventoryBox( renderer ); + + rh.setBounds( 2, 2, 14, 14, 14, 15 ); + rh.renderInventoryBox( renderer ); + + rh.setBounds( 5, 5, 12, 11, 11, 14 ); + rh.renderInventoryBox( renderer ); + } + + @Override + @SideOnly( Side.CLIENT ) + public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ) + { + this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); + rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() ); + + rh.setBounds( 3, 3, 15, 13, 13, 16 ); + rh.renderBlock( x, y, z, renderer ); + + rh.setBounds( 2, 2, 14, 14, 14, 15 ); + rh.renderBlock( x, y, z, renderer ); + + rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() ); + + rh.setBounds( 5, 5, 12, 11, 11, 13 ); + rh.renderBlock( x, y, z, renderer ); + + rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() ); + + rh.setBounds( 5, 5, 13, 11, 11, 14 ); + rh.renderBlock( x, y, z, renderer ); + + this.renderLights( x, y, z, rh, renderer ); + } + + @Override + public void onNeighborChanged() + { + this.resetCache( false ); + } private void resetCache( boolean fullReset ) { @@ -204,6 +293,53 @@ public class PartStorageBus } } + @Override + public void getBoxes( IPartCollisionHelper bch ) + { + bch.addBox( 3, 3, 15, 13, 13, 16 ); + bch.addBox( 2, 2, 14, 14, 14, 15 ); + bch.addBox( 5, 5, 12, 11, 11, 14 ); + } + + @Override + public int cableConnectionRenderTo() + { + return 4; + } + + @Override + public boolean onPartActivate( EntityPlayer player, Vec3 pos ) + { + if ( !player.isSneaking() ) + { + if ( Platform.isClient() ) + return true; + + Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_STORAGEBUS ); + return true; + } + + return false; + } + + @Override + public TickingRequest getTickingRequest( IGridNode node ) + { + return new TickingRequest( TickRates.StorageBus.min, TickRates.StorageBus.max, this.monitor == null, true ); + } + + @Override + public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) + { + if ( this.resetCacheLogic != 0 ) + this.resetCache(); + + if ( this.monitor != null ) + return this.monitor.onTick(); + + return TickRateModulation.SLEEP; + } + private void resetCache() { boolean fullReset = this.resetCacheLogic == 2; @@ -230,43 +366,6 @@ public class PartStorageBus Platform.postListChanges( before, after, this, this.mySrc ); } - @Override - public void onNeighborChanged() - { - this.resetCache( false ); - } - - @Override - public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack ) - { - super.onChangeInventory( inv, slot, mc, removedStack, newStack ); - - if ( inv == this.Config ) - this.resetCache( true ); - } - - @Override - public void upgradesChanged() - { - super.upgradesChanged(); - this.resetCache( true ); - } - - @Override - public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue ) - { - this.resetCache( true ); - this.host.markForSave(); - } - - @Override - public void setPriority( int newValue ) - { - this.priority = newValue; - this.host.markForSave(); - this.resetCache( true ); - } - public MEInventoryHandler getInternalHandler() { if ( this.cached ) @@ -305,13 +404,13 @@ public class PartStorageBus if ( inv instanceof MEMonitorIInventory ) { - MEMonitorIInventory h = ( MEMonitorIInventory ) inv; - h.mode = ( StorageFilter ) this.getConfigManager().getSetting( Settings.STORAGE_FILTER ); + MEMonitorIInventory h = (MEMonitorIInventory) inv; + h.mode = (StorageFilter) this.getConfigManager().getSetting( Settings.STORAGE_FILTER ); h.mySource = new MachineSource( this ); } if ( inv instanceof MEMonitorIInventory ) - this.monitor = ( MEMonitorIInventory ) inv; + this.monitor = (MEMonitorIInventory) inv; if ( inv != null ) { @@ -334,12 +433,12 @@ public class PartStorageBus } if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) - this.handler.setPartitionList( new FuzzyPriorityList( priorityList, ( FuzzyMode ) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) ); + this.handler.setPartitionList( new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) ); else - this.handler.setPartitionList ( new PrecisePriorityList( priorityList )); + this.handler.setPartitionList( new PrecisePriorityList( priorityList ) ); if ( inv instanceof IMEMonitor ) - ( ( IMEMonitor ) inv ).addListener( this, this.handler ); + ( (IMEMonitor) inv ).addListener( this, this.handler ); } } } @@ -369,13 +468,13 @@ public class PartStorageBus IInterfaceHost achievement = null; if ( target instanceof IInterfaceHost ) - achievement = ( IInterfaceHost ) target; + achievement = (IInterfaceHost) target; if ( target instanceof IPartHost ) { - Object part = ( ( IPartHost ) target ).getPart( side ); + Object part = ( (IPartHost) target ).getPart( side ); if ( part instanceof IInterfaceHost ) - achievement = ( IInterfaceHost ) part; + achievement = (IInterfaceHost) part; } if ( achievement != null && achievement.getActionableNode() != null ) @@ -385,100 +484,6 @@ public class PartStorageBus } } - @Override - @SideOnly( Side.CLIENT ) - public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ) - { - rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(), - this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() ); - - rh.setBounds( 3, 3, 15, 13, 13, 16 ); - rh.renderInventoryBox( renderer ); - - rh.setBounds( 2, 2, 14, 14, 14, 15 ); - rh.renderInventoryBox( renderer ); - - rh.setBounds( 5, 5, 12, 11, 11, 14 ); - rh.renderInventoryBox( renderer ); - } - - @Override - @SideOnly( Side.CLIENT ) - public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ) - { - this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); - rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() ); - - rh.setBounds( 3, 3, 15, 13, 13, 16 ); - rh.renderBlock( x, y, z, renderer ); - - rh.setBounds( 2, 2, 14, 14, 14, 15 ); - rh.renderBlock( x, y, z, renderer ); - - rh.setTexture( CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageBack.getIcon(), - this.is.getIconIndex(), CableBusTextures.PartStorageSides.getIcon(), CableBusTextures.PartStorageSides.getIcon() ); - - rh.setBounds( 5, 5, 12, 11, 11, 13 ); - rh.renderBlock( x, y, z, renderer ); - - rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), - CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), - CableBusTextures.PartMonitorSidesStatus.getIcon() ); - - rh.setBounds( 5, 5, 13, 11, 11, 14 ); - rh.renderBlock( x, y, z, renderer ); - - this.renderLights( x, y, z, rh, renderer ); - } - - @Override - public void getBoxes( IPartCollisionHelper bch ) - { - bch.addBox( 3, 3, 15, 13, 13, 16 ); - bch.addBox( 2, 2, 14, 14, 14, 15 ); - bch.addBox( 5, 5, 12, 11, 11, 14 ); - } - - @Override - public int cableConnectionRenderTo() - { - return 4; - } - - @Override - public TickingRequest getTickingRequest( IGridNode node ) - { - return new TickingRequest( TickRates.StorageBus.min, TickRates.StorageBus.max, this.monitor == null, true ); - } - - @Override - public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) - { - if ( this.resetCacheLogic != 0 ) - this.resetCache(); - - if ( this.monitor != null ) - return this.monitor.onTick(); - - return TickRateModulation.SLEEP; - } - - @Override - public void writeToNBT( NBTTagCompound data ) - { - super.writeToNBT( data ); - this.Config.writeToNBT( data, "config" ); - data.setInteger( "priority", this.priority ); - } - - @Override - public void readFromNBT( NBTTagCompound data ) - { - super.readFromNBT( data ); - this.Config.readFromNBT( data, "config" ); - this.priority = data.getInteger( "priority" ); - } - @Override public List getCellArray( StorageChannel channel ) { @@ -488,7 +493,7 @@ public class PartStorageBus if ( out != null ) return Collections.singletonList( out ); } - return Arrays.asList( new IMEInventoryHandler[] {} ); + return Arrays.asList( new IMEInventoryHandler[] { } ); } @Override @@ -498,21 +503,16 @@ public class PartStorageBus } @Override - public void blinkCell( int slot ) - {} + public void setPriority( int newValue ) + { + this.priority = newValue; + this.host.markForSave(); + this.resetCache( true ); + } @Override - public void postChange( IBaseMonitor monitor, Iterable change, BaseActionSource source ) + public void blinkCell( int slot ) { - try - { - if ( this.proxy.isActive() ) - this.proxy.getStorage().postAlterationOfStoredItems( StorageChannel.ITEMS, change, this.mySrc ); - } - catch ( GridAccessException e ) - { - // :( - } } @Override @@ -522,12 +522,6 @@ public class PartStorageBus return type == PipeType.ITEM && with == this.side ? ConnectOverride.CONNECT : ConnectOverride.DISCONNECT; } - @Override - public void onListUpdate() - { - // not used here. - } - @Override public void saveChanges( IMEInventory cellInventory ) { diff --git a/src/main/java/appeng/parts/misc/PartToggleBus.java b/src/main/java/appeng/parts/misc/PartToggleBus.java index 4c72e1db6..e992adc5e 100644 --- a/src/main/java/appeng/parts/misc/PartToggleBus.java +++ b/src/main/java/appeng/parts/misc/PartToggleBus.java @@ -18,6 +18,7 @@ package appeng.parts.misc; + import java.util.ArrayList; import java.util.EnumSet; import java.util.List; @@ -44,113 +45,41 @@ import appeng.api.parts.IPartHost; import appeng.api.parts.IPartRenderHelper; import appeng.api.util.AECableType; import appeng.client.texture.CableBusTextures; +import appeng.helpers.Reflected; import appeng.me.helpers.AENetworkProxy; import appeng.parts.PartBasicState; import appeng.util.Platform; + public class PartToggleBus extends PartBasicState { - + protected final int REDSTONE_FLAG = 4; final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", null, true ); IGridConnection connection; - - protected final int REDSTONE_FLAG = 4; - boolean hasRedstone = false; - @Override - public void onPlacement(EntityPlayer player, ItemStack held, ForgeDirection side) + @Reflected + public PartToggleBus( ItemStack is ) { - super.onPlacement( player, held, side ); - this.outerProxy.setOwner( player ); - } + super( is ); - @Override - protected int populateFlags(int cf) - { - return cf | (this.getIntention() ? this.REDSTONE_FLAG : 0); - } - - @Override - public void onNeighborChanged() - { - boolean oldHasRedstone = this.hasRedstone; - this.hasRedstone = this.getHost().hasRedstone( this.side ); - - if ( this.hasRedstone != oldHasRedstone ) - { - this.updateInternalState(); - this.getHost().markForUpdate(); - } - } - - public PartToggleBus(ItemStack is) { - this( PartToggleBus.class, is ); this.proxy.setIdlePowerUsage( 0.0 ); this.outerProxy.setIdlePowerUsage( 0.0 ); this.proxy.setFlags(); this.outerProxy.setFlags(); } - public PartToggleBus(Class cls, ItemStack is) { - super( cls, is ); + @Override + public void setColors( boolean hasChan, boolean hasPower ) + { + this.hasRedstone = ( this.clientFlags & this.REDSTONE_FLAG ) == this.REDSTONE_FLAG; + super.setColors( hasChan && this.hasRedstone, hasPower && this.hasRedstone ); } @Override - public void setPartHostInfo(ForgeDirection side, IPartHost host, TileEntity tile) + protected int populateFlags( int cf ) { - super.setPartHostInfo( side, host, tile ); - this.outerProxy.setValidSides( EnumSet.of( side ) ); - } - - @Override - public void readFromNBT(NBTTagCompound extra) - { - super.readFromNBT( extra ); - this.outerProxy.readFromNBT( extra ); - } - - @Override - public void writeToNBT(NBTTagCompound extra) - { - super.writeToNBT( extra ); - this.outerProxy.writeToNBT( extra ); - } - - @Override - public void addToWorld() - { - super.addToWorld(); - this.outerProxy.onReady(); - this.hasRedstone = this.getHost().hasRedstone( this.side ); - this.updateInternalState(); - } - - private void updateInternalState() - { - boolean intention = this.getIntention(); - if ( intention == ( this.connection == null ) ) - { - if ( this.proxy.getNode() != null && this.outerProxy.getNode() != null ) - { - if ( intention ) - { - try - { - this.connection = AEApi.instance().createGridConnection( this.proxy.getNode(), this.outerProxy.getNode() ); - } - catch (FailedConnection e) - { - // :( - } - } - else - { - this.connection.destroy(); - this.connection = null; - } - } - } + return cf | ( this.getIntention() ? this.REDSTONE_FLAG : 0 ); } protected boolean getIntention() @@ -158,55 +87,6 @@ public class PartToggleBus extends PartBasicState return this.getHost().hasRedstone( this.side ); } - @Override - public void removeFromWorld() - { - super.removeFromWorld(); - this.outerProxy.invalidate(); - } - - @Override - public IGridNode getExternalFacingNode() - { - return this.outerProxy.getNode(); - } - - @Override - public AECableType getCableConnectionType(ForgeDirection dir) - { - return AECableType.GLASS; - } - - @Override - public void setColors(boolean hasChan, boolean hasPower) - { - this.hasRedstone = (this.clientFlags & this.REDSTONE_FLAG) == this.REDSTONE_FLAG; - super.setColors( hasChan && this.hasRedstone, hasPower && this.hasRedstone ); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer) - { - this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); - rh.setTexture( this.is.getIconIndex() ); - - rh.setBounds( 6, 6, 14, 10, 10, 16 ); - rh.renderBlock( x, y, z, renderer ); - - rh.setBounds( 6, 6, 11, 10, 10, 13 ); - rh.renderBlock( x, y, z, renderer ); - - rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), - CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), - CableBusTextures.PartMonitorSidesStatus.getIcon() ); - - rh.setBounds( 6, 6, 13, 10, 10, 14 ); - rh.renderBlock( x, y, z, renderer ); - - this.renderLights( x, y, z, rh, renderer ); - } - @Override public IIcon getBreakingTexture() { @@ -214,14 +94,8 @@ public class PartToggleBus extends PartBasicState } @Override - public void getBoxes(IPartCollisionHelper bch) - { - bch.addBox( 6, 6, 11, 10, 10, 16 ); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) + @SideOnly( Side.CLIENT ) + public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ) { GL11.glTranslated( -0.2, -0.3, 0.0 ); @@ -244,12 +118,108 @@ public class PartToggleBus extends PartBasicState rh.setTexture( null ); } + @Override + @SideOnly( Side.CLIENT ) + public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ) + { + this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); + rh.setTexture( this.is.getIconIndex() ); + + rh.setBounds( 6, 6, 14, 10, 10, 16 ); + rh.renderBlock( x, y, z, renderer ); + + rh.setBounds( 6, 6, 11, 10, 10, 13 ); + rh.renderBlock( x, y, z, renderer ); + + rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() ); + + rh.setBounds( 6, 6, 13, 10, 10, 14 ); + rh.renderBlock( x, y, z, renderer ); + + this.renderLights( x, y, z, rh, renderer ); + } + + @Override + public void onNeighborChanged() + { + boolean oldHasRedstone = this.hasRedstone; + this.hasRedstone = this.getHost().hasRedstone( this.side ); + + if ( this.hasRedstone != oldHasRedstone ) + { + this.updateInternalState(); + this.getHost().markForUpdate(); + } + } + + @Override + public void readFromNBT( NBTTagCompound extra ) + { + super.readFromNBT( extra ); + this.outerProxy.readFromNBT( extra ); + } + + @Override + public void writeToNBT( NBTTagCompound extra ) + { + super.writeToNBT( extra ); + this.outerProxy.writeToNBT( extra ); + } + + @Override + public void removeFromWorld() + { + super.removeFromWorld(); + this.outerProxy.invalidate(); + } + + @Override + public void addToWorld() + { + super.addToWorld(); + this.outerProxy.onReady(); + this.hasRedstone = this.getHost().hasRedstone( this.side ); + this.updateInternalState(); + } + + @Override + public void setPartHostInfo( ForgeDirection side, IPartHost host, TileEntity tile ) + { + super.setPartHostInfo( side, host, tile ); + this.outerProxy.setValidSides( EnumSet.of( side ) ); + } + + @Override + public IGridNode getExternalFacingNode() + { + return this.outerProxy.getNode(); + } + + @Override + public void getBoxes( IPartCollisionHelper bch ) + { + bch.addBox( 6, 6, 11, 10, 10, 16 ); + } + + @Override + public AECableType getCableConnectionType( ForgeDirection dir ) + { + return AECableType.GLASS; + } + @Override public int cableConnectionRenderTo() { return 5; } + @Override + public void onPlacement( EntityPlayer player, ItemStack held, ForgeDirection side ) + { + super.onPlacement( player, held, side ); + this.outerProxy.setOwner( player ); + } + @Override public void securityBreak() { @@ -262,4 +232,31 @@ public class PartToggleBus extends PartBasicState this.is.stackSize = 0; } } + + private void updateInternalState() + { + boolean intention = this.getIntention(); + if ( intention == ( this.connection == null ) ) + { + if ( this.proxy.getNode() != null && this.outerProxy.getNode() != null ) + { + if ( intention ) + { + try + { + this.connection = AEApi.instance().createGridConnection( this.proxy.getNode(), this.outerProxy.getNode() ); + } + catch ( FailedConnection e ) + { + // :( + } + } + else + { + this.connection.destroy(); + this.connection = null; + } + } + } + } } diff --git a/src/main/java/appeng/parts/networking/PartCable.java b/src/main/java/appeng/parts/networking/PartCable.java index d7cb1bec7..821f03c89 100644 --- a/src/main/java/appeng/parts/networking/PartCable.java +++ b/src/main/java/appeng/parts/networking/PartCable.java @@ -40,6 +40,7 @@ import cpw.mods.fml.relauncher.SideOnly; import appeng.api.AEApi; import appeng.api.config.SecurityPermissions; +import appeng.api.definitions.IParts; import appeng.api.implementations.parts.IPartCable; import appeng.api.networking.GridFlags; import appeng.api.networking.IGridConnection; @@ -52,6 +53,7 @@ import appeng.api.parts.IPartHost; import appeng.api.parts.IPartRenderHelper; import appeng.api.util.AECableType; import appeng.api.util.AEColor; +import appeng.api.util.AEColoredItemDefinition; import appeng.api.util.IReadOnlyCollection; import appeng.block.AEBaseBlock; import appeng.client.texture.CableBusTextures; @@ -72,9 +74,9 @@ public class PartCable extends AEBasePart implements IPartCable EnumSet connections = EnumSet.noneOf( ForgeDirection.class ); boolean powered = false; - public PartCable( Class c, ItemStack is ) + public PartCable( ItemStack is ) { - super( c, is ); + super( is ); this.proxy.setFlags( GridFlags.PREFERRED ); this.proxy.setIdlePowerUsage( 0.0 ); this.proxy.myColor = AEColor.values()[( ( ItemMultiPart ) is.getItem() ).variantOf( is.getItemDamage() )]; @@ -130,8 +132,11 @@ public class PartCable extends AEBasePart implements IPartCable return CableBusTextures.MECable_Yellow.getIcon(); default: } - return AEApi.instance().parts().partCableGlass.item( AEColor.Transparent ).getIconIndex( - AEApi.instance().parts().partCableGlass.stack( AEColor.Transparent, 1 ) ); + + final AEColoredItemDefinition glassCable = AEApi.instance().definitions().parts().cableGlass(); + final ItemStack glassCableStack = glassCable.stack( AEColor.Transparent, 1 ); + + return glassCable.item( AEColor.Transparent ).getIconIndex( glassCableStack ); } public IIcon getTexture( AEColor c ) @@ -177,8 +182,11 @@ public class PartCable extends AEBasePart implements IPartCable return CableBusTextures.MECovered_Yellow.getIcon(); default: } - return AEApi.instance().parts().partCableCovered.item( AEColor.Transparent ).getIconIndex( - AEApi.instance().parts().partCableCovered.stack( AEColor.Transparent, 1 ) ); + + final AEColoredItemDefinition coveredCable = AEApi.instance().definitions().parts().cableCovered(); + final ItemStack coveredCableStack = coveredCable.stack( AEColor.Transparent, 1 ); + + return coveredCable.item( AEColor.Transparent ).getIconIndex( coveredCableStack ); } public IIcon getSmartTexture( AEColor c ) @@ -219,8 +227,11 @@ public class PartCable extends AEBasePart implements IPartCable return CableBusTextures.MESmart_Yellow.getIcon(); default: } - return AEApi.instance().parts().partCableCovered.item( AEColor.Transparent ).getIconIndex( - AEApi.instance().parts().partCableSmart.stack( AEColor.Transparent, 1 ) ); + + final IParts parts = AEApi.instance().definitions().parts(); + final ItemStack smartCableStack = parts.cableSmart().stack( AEColor.Transparent, 1 ); + + return parts.cableCovered().item( AEColor.Transparent ).getIconIndex( smartCableStack ); } @Override @@ -1009,21 +1020,23 @@ public class PartCable extends AEBasePart implements IPartCable { ItemStack newPart = null; + final IParts parts = AEApi.instance().definitions().parts(); + if ( this.getCableConnectionType() == AECableType.GLASS ) { - newPart = AEApi.instance().parts().partCableGlass.stack( newColor, 1 ); + newPart = parts.cableGlass().stack( newColor, 1 ); } else if ( this.getCableConnectionType() == AECableType.COVERED ) { - newPart = AEApi.instance().parts().partCableCovered.stack( newColor, 1 ); + newPart = parts.cableCovered().stack( newColor, 1 ); } else if ( this.getCableConnectionType() == AECableType.SMART ) { - newPart = AEApi.instance().parts().partCableSmart.stack( newColor, 1 ); + newPart = parts.cableSmart().stack( newColor, 1 ); } else if ( this.getCableConnectionType() == AECableType.DENSE ) { - newPart = AEApi.instance().parts().partCableDense.stack( newColor, 1 ); + newPart = parts.cableDense().stack( newColor, 1 ); } boolean hasPermission = true; diff --git a/src/main/java/appeng/parts/networking/PartCableCovered.java b/src/main/java/appeng/parts/networking/PartCableCovered.java index 9a337e00a..42dce8683 100644 --- a/src/main/java/appeng/parts/networking/PartCableCovered.java +++ b/src/main/java/appeng/parts/networking/PartCableCovered.java @@ -18,6 +18,7 @@ package appeng.parts.networking; + import java.util.EnumSet; import org.lwjgl.opengl.GL11; @@ -42,33 +43,32 @@ import appeng.api.parts.IPartRenderHelper; import appeng.api.util.AECableType; import appeng.api.util.AEColor; import appeng.client.texture.OffsetIcon; +import appeng.helpers.Reflected; import appeng.util.Platform; + public class PartCableCovered extends PartCable { + @Reflected + public PartCableCovered( ItemStack is ) + { + super( is ); + } @MENetworkEventSubscribe - public void channelUpdated(MENetworkChannelsChanged c) + public void channelUpdated( MENetworkChannelsChanged c ) { this.getHost().markForUpdate(); } @MENetworkEventSubscribe - public void powerRender(MENetworkPowerStatusChange c) + public void powerRender( MENetworkPowerStatusChange c ) { this.getHost().markForUpdate(); } - public PartCableCovered(Class c, ItemStack is) { - super( c, is ); - } - - public PartCableCovered(ItemStack is) { - this( PartCableCovered.class, is ); - } - @Override - public IIcon getTexture(AEColor c) + public IIcon getTexture( AEColor c ) { return this.getCoveredTexture( c ); } @@ -80,7 +80,7 @@ public class PartCableCovered extends PartCable } @Override - public void getBoxes(IPartCollisionHelper bch) + public void getBoxes( IPartCollisionHelper bch ) { bch.addBox( 5.0, 5.0, 5.0, 11.0, 11.0, 11.0 ); @@ -93,36 +93,36 @@ public class PartCableCovered extends PartCable this.connections.clear(); } - for (ForgeDirection of : this.connections) + for ( ForgeDirection of : this.connections ) { - switch (of) + switch ( of ) { - case DOWN: - bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 ); - break; - case EAST: - bch.addBox( 11.0, 5.0, 5.0, 16.0, 11.0, 11.0 ); - break; - case NORTH: - bch.addBox( 5.0, 5.0, 0.0, 11.0, 11.0, 5.0 ); - break; - case SOUTH: - bch.addBox( 5.0, 5.0, 11.0, 11.0, 11.0, 16.0 ); - break; - case UP: - bch.addBox( 5.0, 11.0, 5.0, 11.0, 16.0, 11.0 ); - break; - case WEST: - bch.addBox( 0.0, 5.0, 5.0, 5.0, 11.0, 11.0 ); - break; - default: + case DOWN: + bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 ); + break; + case EAST: + bch.addBox( 11.0, 5.0, 5.0, 16.0, 11.0, 11.0 ); + break; + case NORTH: + bch.addBox( 5.0, 5.0, 0.0, 11.0, 11.0, 5.0 ); + break; + case SOUTH: + bch.addBox( 5.0, 5.0, 11.0, 11.0, 11.0, 16.0 ); + break; + case UP: + bch.addBox( 5.0, 11.0, 5.0, 11.0, 16.0, 11.0 ); + break; + case WEST: + bch.addBox( 0.0, 5.0, 5.0, 5.0, 11.0, 11.0 ); + break; + default: } } } @Override - @SideOnly(Side.CLIENT) - public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) + @SideOnly( Side.CLIENT ) + public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ) { GL11.glTranslated( -0.0, -0.0, 0.3 ); @@ -132,7 +132,7 @@ public class PartCableCovered extends PartCable OffsetIcon main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV ); - for (ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN )) + for ( ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) ) { rh.renderInventoryFace( main, side, renderer ); } @@ -141,14 +141,14 @@ public class PartCableCovered extends PartCable offV = 0; main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV ); - for (ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST )) + for ( ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST ) ) { rh.renderInventoryFace( main, side, renderer ); } main = new OffsetIcon( this.getTexture( this.getCableColor() ), 0, 0 ); - for (ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH )) + for ( ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH ) ) { rh.renderInventoryFace( main, side, renderer ); } @@ -157,8 +157,8 @@ public class PartCableCovered extends PartCable } @Override - @SideOnly(Side.CLIENT) - public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer) + @SideOnly( Side.CLIENT ) + public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ) { this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); rh.setTexture( this.getTexture( this.getCableColor() ) ); @@ -167,7 +167,7 @@ public class PartCableCovered extends PartCable boolean hasBuses = false; IPartHost ph = this.getHost(); - for (ForgeDirection of : EnumSet.complementOf( this.connections )) + for ( ForgeDirection of : EnumSet.complementOf( this.connections ) ) { IPart bp = ph.getPart( of ); if ( bp instanceof IGridHost ) @@ -181,28 +181,28 @@ public class PartCableCovered extends PartCable int len = bp.cableConnectionRenderTo(); if ( len < 8 ) { - switch (of) + switch ( of ) { - case DOWN: - rh.setBounds( 6, len, 6, 10, 5, 10 ); - break; - case EAST: - rh.setBounds( 11, 6, 6, 16 - len, 10, 10 ); - break; - case NORTH: - rh.setBounds( 6, 6, len, 10, 10, 5 ); - break; - case SOUTH: - rh.setBounds( 6, 6, 11, 10, 10, 16 - len ); - break; - case UP: - rh.setBounds( 6, 11, 6, 10, 16 - len, 10 ); - break; - case WEST: - rh.setBounds( len, 6, 6, 5, 10, 10 ); - break; - default: - continue; + case DOWN: + rh.setBounds( 6, len, 6, 10, 5, 10 ); + break; + case EAST: + rh.setBounds( 11, 6, 6, 16 - len, 10, 10 ); + break; + case NORTH: + rh.setBounds( 6, 6, len, 10, 10, 5 ); + break; + case SOUTH: + rh.setBounds( 6, 6, 11, 10, 10, 16 - len ); + break; + case UP: + rh.setBounds( 6, 11, 6, 10, 16 - len, 10 ); + break; + case WEST: + rh.setBounds( len, 6, 6, 5, 10, 10 ); + break; + default: + continue; } rh.renderBlock( x, y, z, renderer ); } @@ -211,7 +211,7 @@ public class PartCableCovered extends PartCable if ( sides.size() != 2 || !this.nonLinear( sides ) || hasBuses ) { - for (ForgeDirection of : this.connections) + for ( ForgeDirection of : this.connections ) { this.renderCoveredConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of ); } @@ -224,29 +224,29 @@ public class PartCableCovered extends PartCable { IIcon def = this.getTexture( this.getCableColor() ); IIcon off = new OffsetIcon( def, 0, -12 ); - for (ForgeDirection of : this.connections) + for ( ForgeDirection of : this.connections ) { - switch (of) + switch ( of ) { - case DOWN: - case UP: - rh.setTexture( def, def, off, off, off, off ); - renderer.setRenderBounds( 5 / 16.0, 0, 5 / 16.0, 11 / 16.0, 16 / 16.0, 11 / 16.0 ); - break; - case EAST: - case WEST: - rh.setTexture( off, off, off, off, def, def ); - renderer.uvRotateEast = renderer.uvRotateWest = 1; - renderer.uvRotateBottom = renderer.uvRotateTop = 1; - renderer.setRenderBounds( 0, 5 / 16.0, 5 / 16.0, 16 / 16.0, 11 / 16.0, 11 / 16.0 ); - break; - case NORTH: - case SOUTH: - rh.setTexture( off, off, def, def, off, off ); - renderer.uvRotateNorth = renderer.uvRotateSouth = 1; - renderer.setRenderBounds( 5 / 16.0, 5 / 16.0, 0, 11 / 16.0, 11 / 16.0, 16 / 16.0 ); - break; - default: + case DOWN: + case UP: + rh.setTexture( def, def, off, off, off, off ); + renderer.setRenderBounds( 5 / 16.0, 0, 5 / 16.0, 11 / 16.0, 16 / 16.0, 11 / 16.0 ); + break; + case EAST: + case WEST: + rh.setTexture( off, off, off, off, def, def ); + renderer.uvRotateEast = renderer.uvRotateWest = 1; + renderer.uvRotateBottom = renderer.uvRotateTop = 1; + renderer.setRenderBounds( 0, 5 / 16.0, 5 / 16.0, 16 / 16.0, 11 / 16.0, 11 / 16.0 ); + break; + case NORTH: + case SOUTH: + rh.setTexture( off, off, def, def, off, off ); + renderer.uvRotateNorth = renderer.uvRotateSouth = 1; + renderer.setRenderBounds( 5 / 16.0, 5 / 16.0, 0, 11 / 16.0, 11 / 16.0, 16 / 16.0 ); + break; + default: } } @@ -256,5 +256,4 @@ public class PartCableCovered extends PartCable renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0; rh.setTexture( null ); } - } diff --git a/src/main/java/appeng/parts/networking/PartCableGlass.java b/src/main/java/appeng/parts/networking/PartCableGlass.java index 397ce9db3..246d0760c 100644 --- a/src/main/java/appeng/parts/networking/PartCableGlass.java +++ b/src/main/java/appeng/parts/networking/PartCableGlass.java @@ -18,17 +18,17 @@ package appeng.parts.networking; + import net.minecraft.item.ItemStack; +import appeng.helpers.Reflected; + + public class PartCableGlass extends PartCable { - - public PartCableGlass(Class c, ItemStack is) { - super( c, is ); + @Reflected + public PartCableGlass( ItemStack is ) + { + super( is ); } - - public PartCableGlass(ItemStack is) { - this( PartCableGlass.class, is ); - } - } diff --git a/src/main/java/appeng/parts/networking/PartCableSmart.java b/src/main/java/appeng/parts/networking/PartCableSmart.java index bd5128952..761c89f19 100644 --- a/src/main/java/appeng/parts/networking/PartCableSmart.java +++ b/src/main/java/appeng/parts/networking/PartCableSmart.java @@ -18,6 +18,7 @@ package appeng.parts.networking; + import java.util.EnumSet; import org.lwjgl.opengl.GL11; @@ -46,31 +47,30 @@ import appeng.block.AEBaseBlock; import appeng.client.texture.FlippableIcon; import appeng.client.texture.OffsetIcon; import appeng.client.texture.TaughtIcon; +import appeng.helpers.Reflected; import appeng.util.Platform; + public class PartCableSmart extends PartCable { + @Reflected + public PartCableSmart( ItemStack is ) + { + super( is ); + } @MENetworkEventSubscribe - public void channelUpdated(MENetworkChannelsChanged c) + public void channelUpdated( MENetworkChannelsChanged c ) { this.getHost().markForUpdate(); } @MENetworkEventSubscribe - public void powerRender(MENetworkPowerStatusChange c) + public void powerRender( MENetworkPowerStatusChange c ) { this.getHost().markForUpdate(); } - public PartCableSmart(Class c, ItemStack is) { - super( c, is ); - } - - public PartCableSmart(ItemStack is) { - this( PartCableSmart.class, is ); - } - @Override public AECableType getCableConnectionType() { @@ -78,14 +78,14 @@ public class PartCableSmart extends PartCable } @Override - public IIcon getTexture(AEColor c) + public IIcon getTexture( AEColor c ) { return this.getSmartTexture( c ); } @Override - @SideOnly(Side.CLIENT) - public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) + @SideOnly( Side.CLIENT ) + public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ) { GL11.glTranslated( -0.0, -0.0, 0.3 ); @@ -96,7 +96,7 @@ public class PartCableSmart extends PartCable OffsetIcon ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV ); OffsetIcon ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV ); - for (ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN )) + for ( ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) ) { rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f ); rh.renderInventoryFace( main, side, renderer ); @@ -110,7 +110,7 @@ public class PartCableSmart extends PartCable ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV ); ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV ); - for (ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST )) + for ( ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST ) ) { rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f ); rh.renderInventoryFace( main, side, renderer ); @@ -122,7 +122,7 @@ public class PartCableSmart extends PartCable ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), 0, 0 ); ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), 0, 0 ); - for (ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH )) + for ( ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH ) ) { rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f ); rh.renderInventoryFace( main, side, renderer ); @@ -134,7 +134,7 @@ public class PartCableSmart extends PartCable } @Override - public void getBoxes(IPartCollisionHelper bch) + public void getBoxes( IPartCollisionHelper bch ) { bch.addBox( 5.0, 5.0, 5.0, 11.0, 11.0, 11.0 ); @@ -147,36 +147,36 @@ public class PartCableSmart extends PartCable this.connections.clear(); } - for (ForgeDirection of : this.connections) + for ( ForgeDirection of : this.connections ) { - switch (of) + switch ( of ) { - case DOWN: - bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 ); - break; - case EAST: - bch.addBox( 11.0, 5.0, 5.0, 16.0, 11.0, 11.0 ); - break; - case NORTH: - bch.addBox( 5.0, 5.0, 0.0, 11.0, 11.0, 5.0 ); - break; - case SOUTH: - bch.addBox( 5.0, 5.0, 11.0, 11.0, 11.0, 16.0 ); - break; - case UP: - bch.addBox( 5.0, 11.0, 5.0, 11.0, 16.0, 11.0 ); - break; - case WEST: - bch.addBox( 0.0, 5.0, 5.0, 5.0, 11.0, 11.0 ); - break; - default: + case DOWN: + bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 ); + break; + case EAST: + bch.addBox( 11.0, 5.0, 5.0, 16.0, 11.0, 11.0 ); + break; + case NORTH: + bch.addBox( 5.0, 5.0, 0.0, 11.0, 11.0, 5.0 ); + break; + case SOUTH: + bch.addBox( 5.0, 5.0, 11.0, 11.0, 11.0, 16.0 ); + break; + case UP: + bch.addBox( 5.0, 11.0, 5.0, 11.0, 16.0, 11.0 ); + break; + case WEST: + bch.addBox( 0.0, 5.0, 5.0, 5.0, 11.0, 11.0 ); + break; + default: } } } @Override - @SideOnly(Side.CLIENT) - public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer) + @SideOnly( Side.CLIENT ) + public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ) { this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); rh.setTexture( this.getTexture( this.getCableColor() ) ); @@ -185,7 +185,7 @@ public class PartCableSmart extends PartCable boolean hasBuses = false; IPartHost ph = this.getHost(); - for (ForgeDirection of : EnumSet.complementOf( this.connections )) + for ( ForgeDirection of : EnumSet.complementOf( this.connections ) ) { IPart bp = ph.getPart( of ); if ( bp instanceof IGridHost ) @@ -199,28 +199,28 @@ public class PartCableSmart extends PartCable int len = bp.cableConnectionRenderTo(); if ( len < 8 ) { - switch (of) + switch ( of ) { - case DOWN: - rh.setBounds( 6, len, 6, 10, 5, 10 ); - break; - case EAST: - rh.setBounds( 11, 6, 6, 16 - len, 10, 10 ); - break; - case NORTH: - rh.setBounds( 6, 6, len, 10, 10, 5 ); - break; - case SOUTH: - rh.setBounds( 6, 6, 11, 10, 10, 16 - len ); - break; - case UP: - rh.setBounds( 6, 11, 6, 10, 16 - len, 10 ); - break; - case WEST: - rh.setBounds( len, 6, 6, 5, 10, 10 ); - break; - default: - continue; + case DOWN: + rh.setBounds( 6, len, 6, 10, 5, 10 ); + break; + case EAST: + rh.setBounds( 11, 6, 6, 16 - len, 10, 10 ); + break; + case NORTH: + rh.setBounds( 6, 6, len, 10, 10, 5 ); + break; + case SOUTH: + rh.setBounds( 6, 6, 11, 10, 10, 16 - len ); + break; + case UP: + rh.setBounds( 6, 11, 6, 10, 16 - len, 10 ); + break; + case WEST: + rh.setBounds( len, 6, 6, 5, 10, 10 ); + break; + default: + continue; } rh.renderBlock( x, y, z, renderer ); @@ -253,7 +253,7 @@ public class PartCableSmart extends PartCable if ( sides.size() != 2 || !this.nonLinear( sides ) || hasBuses ) { - for (ForgeDirection of : this.connections) + for ( ForgeDirection of : this.connections ) { this.renderSmartConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of ); } @@ -266,7 +266,7 @@ public class PartCableSmart extends PartCable { ForgeDirection selectedSide = ForgeDirection.UNKNOWN; - for (ForgeDirection of : this.connections) + for ( ForgeDirection of : this.connections ) { selectedSide = of; break; @@ -282,88 +282,88 @@ public class PartCableSmart extends PartCable IIcon secondTaughtIcon = new TaughtIcon( this.getChannelTex( channels, true ).getIcon(), -0.2f ); IIcon secondOffsetIcon = new OffsetIcon( secondTaughtIcon, 0, -12 ); - switch (selectedSide) + switch ( selectedSide ) { - case DOWN: - case UP: - renderer.setRenderBounds( 5 / 16.0, 0, 5 / 16.0, 11 / 16.0, 16 / 16.0, 11 / 16.0 ); - rh.setTexture( def, def, off, off, off, off ); - rh.renderBlockCurrentBounds( x, y, z, renderer ); + case DOWN: + case UP: + renderer.setRenderBounds( 5 / 16.0, 0, 5 / 16.0, 11 / 16.0, 16 / 16.0, 11 / 16.0 ); + rh.setTexture( def, def, off, off, off, off ); + rh.renderBlockCurrentBounds( x, y, z, renderer ); - renderer.uvRotateTop = 0; - renderer.uvRotateBottom = 0; - renderer.uvRotateSouth = 3; - renderer.uvRotateEast = 3; + renderer.uvRotateTop = 0; + renderer.uvRotateBottom = 0; + renderer.uvRotateSouth = 3; + renderer.uvRotateEast = 3; - Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 ); + Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 ); - Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant ); - rh.setTexture( firstTaughtIcon, firstTaughtIcon, firstOffsetIcon, firstOffsetIcon, firstOffsetIcon, firstOffsetIcon ); - this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); + Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant ); + rh.setTexture( firstTaughtIcon, firstTaughtIcon, firstOffsetIcon, firstOffsetIcon, firstOffsetIcon, firstOffsetIcon ); + this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); - Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant ); - rh.setTexture( secondTaughtIcon, secondTaughtIcon, secondOffsetIcon, secondOffsetIcon, secondOffsetIcon, secondOffsetIcon ); - this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); - break; - case EAST: - case WEST: - rh.setTexture( off, off, off, off, def, def ); - renderer.uvRotateEast = 2; - renderer.uvRotateWest = 1; - renderer.uvRotateBottom = 2; - renderer.uvRotateTop = 1; - renderer.uvRotateSouth = 0; - renderer.uvRotateNorth = 0; + Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant ); + rh.setTexture( secondTaughtIcon, secondTaughtIcon, secondOffsetIcon, secondOffsetIcon, secondOffsetIcon, secondOffsetIcon ); + this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); + break; + case EAST: + case WEST: + rh.setTexture( off, off, off, off, def, def ); + renderer.uvRotateEast = 2; + renderer.uvRotateWest = 1; + renderer.uvRotateBottom = 2; + renderer.uvRotateTop = 1; + renderer.uvRotateSouth = 0; + renderer.uvRotateNorth = 0; - AEBaseBlock blk = (AEBaseBlock) rh.getBlock(); - FlippableIcon ico = blk.getRendererInstance().getTexture( ForgeDirection.EAST ); - ico.setFlip( false, true ); + AEBaseBlock blk = (AEBaseBlock) rh.getBlock(); + FlippableIcon ico = blk.getRendererInstance().getTexture( ForgeDirection.EAST ); + ico.setFlip( false, true ); - renderer.setRenderBounds( 0, 5 / 16.0, 5 / 16.0, 16 / 16.0, 11 / 16.0, 11 / 16.0 ); - rh.renderBlockCurrentBounds( x, y, z, renderer ); + renderer.setRenderBounds( 0, 5 / 16.0, 5 / 16.0, 16 / 16.0, 11 / 16.0, 11 / 16.0 ); + rh.renderBlockCurrentBounds( x, y, z, renderer ); - Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 ); + Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 ); - FlippableIcon fpA = new FlippableIcon( firstTaughtIcon ); - FlippableIcon fpB = new FlippableIcon( secondTaughtIcon ); + FlippableIcon fpA = new FlippableIcon( firstTaughtIcon ); + FlippableIcon fpB = new FlippableIcon( secondTaughtIcon ); - fpA = new FlippableIcon( firstTaughtIcon ); - fpB = new FlippableIcon( secondTaughtIcon ); + fpA = new FlippableIcon( firstTaughtIcon ); + fpB = new FlippableIcon( secondTaughtIcon ); - fpA.setFlip( true, false ); - fpB.setFlip( true, false ); + fpA.setFlip( true, false ); + fpB.setFlip( true, false ); - Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant ); - rh.setTexture( firstOffsetIcon, firstOffsetIcon, firstOffsetIcon, firstOffsetIcon, firstTaughtIcon, fpA ); - this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); + Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant ); + rh.setTexture( firstOffsetIcon, firstOffsetIcon, firstOffsetIcon, firstOffsetIcon, firstTaughtIcon, fpA ); + this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); - Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant ); - rh.setTexture( secondOffsetIcon, secondOffsetIcon, secondOffsetIcon, secondOffsetIcon, secondTaughtIcon, fpB ); - this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); - break; - case NORTH: - case SOUTH: - rh.setTexture( off, off, def, def, off, off ); - renderer.uvRotateTop = 3; - renderer.uvRotateBottom = 3; - renderer.uvRotateNorth = 1; - renderer.uvRotateSouth = 2; - renderer.uvRotateWest = 1; - renderer.setRenderBounds( 5 / 16.0, 5 / 16.0, 0, 11 / 16.0, 11 / 16.0, 16 / 16.0 ); - rh.renderBlockCurrentBounds( x, y, z, renderer ); + Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant ); + rh.setTexture( secondOffsetIcon, secondOffsetIcon, secondOffsetIcon, secondOffsetIcon, secondTaughtIcon, fpB ); + this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); + break; + case NORTH: + case SOUTH: + rh.setTexture( off, off, def, def, off, off ); + renderer.uvRotateTop = 3; + renderer.uvRotateBottom = 3; + renderer.uvRotateNorth = 1; + renderer.uvRotateSouth = 2; + renderer.uvRotateWest = 1; + renderer.setRenderBounds( 5 / 16.0, 5 / 16.0, 0, 11 / 16.0, 11 / 16.0, 16 / 16.0 ); + rh.renderBlockCurrentBounds( x, y, z, renderer ); - Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 ); + Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 ); - Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant ); - rh.setTexture( firstOffsetIcon, firstOffsetIcon, firstTaughtIcon, firstTaughtIcon, firstOffsetIcon, firstOffsetIcon ); - this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); + Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant ); + rh.setTexture( firstOffsetIcon, firstOffsetIcon, firstTaughtIcon, firstTaughtIcon, firstOffsetIcon, firstOffsetIcon ); + this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); - Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant ); - rh.setTexture( secondOffsetIcon, secondOffsetIcon, secondTaughtIcon, secondTaughtIcon, secondOffsetIcon, secondOffsetIcon ); - this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); - break; - default: - break; + Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant ); + rh.setTexture( secondOffsetIcon, secondOffsetIcon, secondTaughtIcon, secondTaughtIcon, secondOffsetIcon, secondOffsetIcon ); + this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); + break; + default: + break; } } diff --git a/src/main/java/appeng/parts/networking/PartDenseCable.java b/src/main/java/appeng/parts/networking/PartDenseCable.java index 006064b7d..1d49c51e6 100644 --- a/src/main/java/appeng/parts/networking/PartDenseCable.java +++ b/src/main/java/appeng/parts/networking/PartDenseCable.java @@ -18,6 +18,7 @@ package appeng.parts.networking; + import java.util.EnumSet; import org.lwjgl.opengl.GL11; @@ -50,10 +51,19 @@ import appeng.client.texture.CableBusTextures; import appeng.client.texture.FlippableIcon; import appeng.client.texture.OffsetIcon; import appeng.client.texture.TaughtIcon; +import appeng.helpers.Reflected; import appeng.util.Platform; + public class PartDenseCable extends PartCable { + @Reflected + public PartDenseCable( ItemStack is ) + { + super( is ); + + this.proxy.setFlags( GridFlags.DENSE_CAPACITY, GridFlags.PREFERRED ); + } @Override public BusSupport supportsBuses() @@ -61,25 +71,15 @@ public class PartDenseCable extends PartCable return BusSupport.DENSE_CABLE; } - @MENetworkEventSubscribe - public void channelUpdated(MENetworkChannelsChanged c) + @Override + public IIcon getTexture( AEColor c ) { - this.getHost().markForUpdate(); - } + if ( c == AEColor.Transparent ) + { + return AEApi.instance().definitions().parts().cableSmart().stack( AEColor.Transparent, 1 ).getIconIndex(); + } - @MENetworkEventSubscribe - public void powerRender(MENetworkPowerStatusChange c) - { - this.getHost().markForUpdate(); - } - - public PartDenseCable(Class c, ItemStack is) { - super( c, is ); - this.proxy.setFlags( GridFlags.DENSE_CAPACITY, GridFlags.PREFERRED ); - } - - public PartDenseCable(ItemStack is) { - this( PartDenseCable.class, is ); + return this.getSmartTexture( c ); } @Override @@ -89,64 +89,7 @@ public class PartDenseCable extends PartCable } @Override - public IIcon getTexture(AEColor c) - { - if ( c == AEColor.Transparent ) - return AEApi.instance().parts().partCableSmart.stack( AEColor.Transparent, 1 ).getIconIndex(); - - return this.getSmartTexture( c ); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) - { - GL11.glTranslated( -0.0, -0.0, 0.3 ); - rh.setBounds( 4.0f, 4.0f, 2.0f, 12.0f, 12.0f, 14.0f ); - - float offU = 0; - float offV = 9; - - OffsetIcon main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV ); - OffsetIcon ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV ); - OffsetIcon ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV ); - - for (ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN )) - { - rh.renderInventoryFace( main, side, renderer ); - rh.renderInventoryFace( ch1, side, renderer ); - rh.renderInventoryFace( ch2, side, renderer ); - } - - offU = 9; - offV = 0; - main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV ); - ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV ); - ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV ); - - for (ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST )) - { - rh.renderInventoryFace( main, side, renderer ); - rh.renderInventoryFace( ch1, side, renderer ); - rh.renderInventoryFace( ch2, side, renderer ); - } - - main = new OffsetIcon( this.getTexture( this.getCableColor() ), 0, 0 ); - ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), 0, 0 ); - ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), 0, 0 ); - - for (ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH )) - { - rh.renderInventoryFace( main, side, renderer ); - rh.renderInventoryFace( ch1, side, renderer ); - rh.renderInventoryFace( ch2, side, renderer ); - } - - rh.setTexture( null ); - } - - @Override - public void getBoxes(IPartCollisionHelper bch) + public void getBoxes( IPartCollisionHelper bch ) { boolean noLadder = !bch.isBBCollision(); double min = noLadder ? 3.0 : 4.9; @@ -163,85 +106,249 @@ public class PartDenseCable extends PartCable this.connections.clear(); } - for (ForgeDirection of : this.connections) + for ( ForgeDirection of : this.connections ) { if ( this.isDense( of ) ) { - switch (of) + switch ( of ) { - case DOWN: - bch.addBox( min, 0.0, min, max, min, max ); - break; - case EAST: - bch.addBox( max, min, min, 16.0, max, max ); - break; - case NORTH: - bch.addBox( min, min, 0.0, max, max, min ); - break; - case SOUTH: - bch.addBox( min, min, max, max, max, 16.0 ); - break; - case UP: - bch.addBox( min, max, min, max, 16.0, max ); - break; - case WEST: - bch.addBox( 0.0, min, min, min, max, max ); - break; - default: + case DOWN: + bch.addBox( min, 0.0, min, max, min, max ); + break; + case EAST: + bch.addBox( max, min, min, 16.0, max, max ); + break; + case NORTH: + bch.addBox( min, min, 0.0, max, max, min ); + break; + case SOUTH: + bch.addBox( min, min, max, max, max, 16.0 ); + break; + case UP: + bch.addBox( min, max, min, max, 16.0, max ); + break; + case WEST: + bch.addBox( 0.0, min, min, min, max, max ); + break; + default: } } else { - switch (of) + switch ( of ) { - case DOWN: - bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 ); - break; - case EAST: - bch.addBox( 11.0, 5.0, 5.0, 16.0, 11.0, 11.0 ); - break; - case NORTH: - bch.addBox( 5.0, 5.0, 0.0, 11.0, 11.0, 5.0 ); - break; - case SOUTH: - bch.addBox( 5.0, 5.0, 11.0, 11.0, 11.0, 16.0 ); - break; - case UP: - bch.addBox( 5.0, 11.0, 5.0, 11.0, 16.0, 11.0 ); - break; - case WEST: - bch.addBox( 0.0, 5.0, 5.0, 5.0, 11.0, 11.0 ); - break; - default: + case DOWN: + bch.addBox( 5.0, 0.0, 5.0, 11.0, 5.0, 11.0 ); + break; + case EAST: + bch.addBox( 11.0, 5.0, 5.0, 16.0, 11.0, 11.0 ); + break; + case NORTH: + bch.addBox( 5.0, 5.0, 0.0, 11.0, 11.0, 5.0 ); + break; + case SOUTH: + bch.addBox( 5.0, 5.0, 11.0, 11.0, 11.0, 16.0 ); + break; + case UP: + bch.addBox( 5.0, 11.0, 5.0, 11.0, 16.0, 11.0 ); + break; + case WEST: + bch.addBox( 0.0, 5.0, 5.0, 5.0, 11.0, 11.0 ); + break; + default: } } } } - private boolean isDense(ForgeDirection of) + @Override + @SideOnly( Side.CLIENT ) + public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ) { - TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + of.offsetX, this.tile.yCoord + of.offsetY, this.tile.zCoord + of.offsetZ ); - if ( te instanceof IGridHost ) + GL11.glTranslated( -0.0, -0.0, 0.3 ); + rh.setBounds( 4.0f, 4.0f, 2.0f, 12.0f, 12.0f, 14.0f ); + + float offU = 0; + float offV = 9; + + OffsetIcon main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV ); + OffsetIcon ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV ); + OffsetIcon ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV ); + + for ( ForgeDirection side : EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) ) { - AECableType t = ((IGridHost) te).getCableConnectionType( of.getOpposite() ); - return t == AECableType.DENSE; + rh.renderInventoryFace( main, side, renderer ); + rh.renderInventoryFace( ch1, side, renderer ); + rh.renderInventoryFace( ch2, side, renderer ); } - return false; + + offU = 9; + offV = 0; + main = new OffsetIcon( this.getTexture( this.getCableColor() ), offU, offV ); + ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), offU, offV ); + ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), offU, offV ); + + for ( ForgeDirection side : EnumSet.of( ForgeDirection.EAST, ForgeDirection.WEST ) ) + { + rh.renderInventoryFace( main, side, renderer ); + rh.renderInventoryFace( ch1, side, renderer ); + rh.renderInventoryFace( ch2, side, renderer ); + } + + main = new OffsetIcon( this.getTexture( this.getCableColor() ), 0, 0 ); + ch1 = new OffsetIcon( this.getChannelTex( 4, false ).getIcon(), 0, 0 ); + ch2 = new OffsetIcon( this.getChannelTex( 4, true ).getIcon(), 0, 0 ); + + for ( ForgeDirection side : EnumSet.of( ForgeDirection.SOUTH, ForgeDirection.NORTH ) ) + { + rh.renderInventoryFace( main, side, renderer ); + rh.renderInventoryFace( ch1, side, renderer ); + rh.renderInventoryFace( ch2, side, renderer ); + } + + rh.setTexture( null ); } - private boolean isSmart(ForgeDirection of) + @Override + @SideOnly( Side.CLIENT ) + public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ) { - TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + of.offsetX, this.tile.yCoord + of.offsetY, this.tile.zCoord + of.offsetZ ); - if ( te instanceof IGridHost ) + this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); + rh.setTexture( this.getTexture( this.getCableColor() ) ); + + EnumSet sides = this.connections.clone(); + + boolean hasBuses = false; + for ( ForgeDirection of : this.connections ) { - AECableType t = ((IGridHost) te).getCableConnectionType( of.getOpposite() ); - return t == AECableType.SMART; + if ( !this.isDense( of ) ) + hasBuses = true; } - return false; + + if ( sides.size() != 2 || !this.nonLinear( sides ) || hasBuses ) + { + for ( ForgeDirection of : this.connections ) + { + if ( this.isDense( of ) ) + this.renderDenseConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of ); + else if ( this.isSmart( of ) ) + this.renderSmartConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of ); + else + this.renderCoveredConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of ); + } + + rh.setTexture( this.getDenseTexture( this.getCableColor() ) ); + rh.setBounds( 3, 3, 3, 13, 13, 13 ); + rh.renderBlock( x, y, z, renderer ); + } + else + { + ForgeDirection selectedSide = ForgeDirection.UNKNOWN; + + for ( ForgeDirection of : this.connections ) + { + selectedSide = of; + break; + } + + int channels = this.channelsOnSide[selectedSide.ordinal()]; + IIcon def = this.getTexture( this.getCableColor() ); + IIcon off = new OffsetIcon( def, 0, -12 ); + + IIcon firstIcon = new TaughtIcon( this.getChannelTex( channels, false ).getIcon(), -0.2f ); + IIcon firstOffset = new OffsetIcon( firstIcon, 0, -12 ); + + IIcon secondIcon = new TaughtIcon( this.getChannelTex( channels, true ).getIcon(), -0.2f ); + IIcon secondOffset = new OffsetIcon( secondIcon, 0, -12 ); + + switch ( selectedSide ) + { + case DOWN: + case UP: + renderer.setRenderBounds( 3 / 16.0, 0, 3 / 16.0, 13 / 16.0, 16 / 16.0, 13 / 16.0 ); + rh.setTexture( def, def, off, off, off, off ); + rh.renderBlockCurrentBounds( x, y, z, renderer ); + + renderer.uvRotateTop = 0; + renderer.uvRotateBottom = 0; + renderer.uvRotateSouth = 3; + renderer.uvRotateEast = 3; + + Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 ); + + Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant ); + rh.setTexture( firstIcon, firstIcon, firstOffset, firstOffset, firstOffset, firstOffset ); + this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); + + Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant ); + rh.setTexture( secondIcon, secondIcon, secondOffset, secondOffset, secondOffset, secondOffset ); + this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); + break; + case EAST: + case WEST: + rh.setTexture( off, off, off, off, def, def ); + renderer.uvRotateEast = 2; + renderer.uvRotateWest = 1; + renderer.uvRotateBottom = 2; + renderer.uvRotateTop = 1; + renderer.uvRotateSouth = 0; + renderer.uvRotateNorth = 0; + + AEBaseBlock blk = (AEBaseBlock) rh.getBlock(); + FlippableIcon ico = blk.getRendererInstance().getTexture( ForgeDirection.EAST ); + ico.setFlip( false, true ); + + renderer.setRenderBounds( 0, 3 / 16.0, 3 / 16.0, 16 / 16.0, 13 / 16.0, 13 / 16.0 ); + rh.renderBlockCurrentBounds( x, y, z, renderer ); + + Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 ); + + FlippableIcon fpA = new FlippableIcon( firstIcon ); + FlippableIcon fpB = new FlippableIcon( secondIcon ); + + fpA.setFlip( true, false ); + fpB.setFlip( true, false ); + + Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant ); + rh.setTexture( firstOffset, firstOffset, firstOffset, firstOffset, firstIcon, fpA ); + this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); + + Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant ); + rh.setTexture( secondOffset, secondOffset, secondOffset, secondOffset, secondIcon, fpB ); + this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); + break; + case NORTH: + case SOUTH: + rh.setTexture( off, off, def, def, off, off ); + renderer.uvRotateTop = 3; + renderer.uvRotateBottom = 3; + renderer.uvRotateNorth = 1; + renderer.uvRotateSouth = 2; + renderer.uvRotateWest = 1; + renderer.setRenderBounds( 3 / 16.0, 3 / 16.0, 0, 13 / 16.0, 13 / 16.0, 16 / 16.0 ); + rh.renderBlockCurrentBounds( x, y, z, renderer ); + + Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 ); + + Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant ); + rh.setTexture( firstOffset, firstOffset, firstIcon, firstIcon, firstOffset, firstOffset ); + this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); + + Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant ); + rh.setTexture( secondOffset, secondOffset, secondIcon, secondIcon, secondOffset, secondOffset ); + this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); + break; + default: + break; + } + } + + renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0; + rh.setTexture( null ); } - @SideOnly(Side.CLIENT) - public void renderDenseConnection(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer, int channels, ForgeDirection of) + @SideOnly( Side.CLIENT ) + public void renderDenseConnection( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer, int channels, ForgeDirection of ) { TileEntity te = this.tile.getWorldObj().getTileEntity( x + of.offsetX, y + of.offsetY, z + of.offsetZ ); IPartHost partHost = te instanceof IPartHost ? (IPartHost) te : null; @@ -280,34 +387,33 @@ public class PartDenseCable extends PartCable */ rh.setFacesToRender( EnumSet.complementOf( EnumSet.of( of, of.getOpposite() ) ) ); - if ( ghh != null && partHost != null && ghh.getCableConnectionType( of ) != AECableType.GLASS && partHost.getColor() != AEColor.Transparent - && partHost.getPart( of.getOpposite() ) == null ) + if ( ghh != null && partHost != null && ghh.getCableConnectionType( of ) != AECableType.GLASS && partHost.getColor() != AEColor.Transparent && partHost.getPart( of.getOpposite() ) == null ) rh.setTexture( this.getTexture( myColor = partHost.getColor() ) ); else rh.setTexture( this.getTexture( this.getCableColor() ) ); - switch (of) + switch ( of ) { - case DOWN: - rh.setBounds( 4, 0, 4, 12, 5, 12 ); - break; - case EAST: - rh.setBounds( 11, 4, 4, 16, 12, 12 ); - break; - case NORTH: - rh.setBounds( 4, 4, 0, 12, 12, 5 ); - break; - case SOUTH: - rh.setBounds( 4, 4, 11, 12, 12, 16 ); - break; - case UP: - rh.setBounds( 4, 11, 4, 12, 16, 12 ); - break; - case WEST: - rh.setBounds( 0, 4, 4, 5, 12, 12 ); - break; - default: - return; + case DOWN: + rh.setBounds( 4, 0, 4, 12, 5, 12 ); + break; + case EAST: + rh.setBounds( 11, 4, 4, 16, 12, 12 ); + break; + case NORTH: + rh.setBounds( 4, 4, 0, 12, 12, 5 ); + break; + case SOUTH: + rh.setBounds( 4, 4, 11, 12, 12, 16 ); + break; + case UP: + rh.setBounds( 4, 11, 4, 12, 16, 12 ); + break; + case WEST: + rh.setBounds( 0, 4, 4, 5, 12, 12 ); + break; + default: + return; } rh.renderBlock( x, y, z, renderer ); @@ -333,183 +439,79 @@ public class PartDenseCable extends PartCable } } - @Override - @SideOnly(Side.CLIENT) - public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer) + private boolean isSmart( ForgeDirection of ) { - this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); - rh.setTexture( this.getTexture( this.getCableColor() ) ); - - EnumSet sides = this.connections.clone(); - - boolean hasBuses = false; - for (ForgeDirection of : this.connections) + TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + of.offsetX, this.tile.yCoord + of.offsetY, this.tile.zCoord + of.offsetZ ); + if ( te instanceof IGridHost ) { - if ( !this.isDense( of ) ) - hasBuses = true; + AECableType t = ( (IGridHost) te ).getCableConnectionType( of.getOpposite() ); + return t == AECableType.SMART; } - - if ( sides.size() != 2 || !this.nonLinear( sides ) || hasBuses ) - { - for (ForgeDirection of : this.connections) - { - if ( this.isDense( of ) ) - this.renderDenseConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of ); - else if ( this.isSmart( of ) ) - this.renderSmartConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of ); - else - this.renderCoveredConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of ); - } - - rh.setTexture( this.getDenseTexture( this.getCableColor() ) ); - rh.setBounds( 3, 3, 3, 13, 13, 13 ); - rh.renderBlock( x, y, z, renderer ); - } - else - { - ForgeDirection selectedSide = ForgeDirection.UNKNOWN; - - for (ForgeDirection of : this.connections) - { - selectedSide = of; - break; - } - - int channels = this.channelsOnSide[selectedSide.ordinal()]; - IIcon def = this.getTexture( this.getCableColor() ); - IIcon off = new OffsetIcon( def, 0, -12 ); - - IIcon firstIcon = new TaughtIcon( this.getChannelTex( channels, false ).getIcon(), -0.2f ); - IIcon firstOffset = new OffsetIcon( firstIcon, 0, -12 ); - - IIcon secondIcon = new TaughtIcon( this.getChannelTex( channels, true ).getIcon(), -0.2f ); - IIcon secondOffset = new OffsetIcon( secondIcon, 0, -12 ); - - switch (selectedSide) - { - case DOWN: - case UP: - renderer.setRenderBounds( 3 / 16.0, 0, 3 / 16.0, 13 / 16.0, 16 / 16.0, 13 / 16.0 ); - rh.setTexture( def, def, off, off, off, off ); - rh.renderBlockCurrentBounds( x, y, z, renderer ); - - renderer.uvRotateTop = 0; - renderer.uvRotateBottom = 0; - renderer.uvRotateSouth = 3; - renderer.uvRotateEast = 3; - - Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 ); - - Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant ); - rh.setTexture( firstIcon, firstIcon, firstOffset, firstOffset, firstOffset, firstOffset ); - this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); - - Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant ); - rh.setTexture( secondIcon, secondIcon, secondOffset, secondOffset, secondOffset, secondOffset ); - this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); - break; - case EAST: - case WEST: - rh.setTexture( off, off, off, off, def, def ); - renderer.uvRotateEast = 2; - renderer.uvRotateWest = 1; - renderer.uvRotateBottom = 2; - renderer.uvRotateTop = 1; - renderer.uvRotateSouth = 0; - renderer.uvRotateNorth = 0; - - AEBaseBlock blk = (AEBaseBlock) rh.getBlock(); - FlippableIcon ico = blk.getRendererInstance().getTexture( ForgeDirection.EAST ); - ico.setFlip( false, true ); - - renderer.setRenderBounds( 0, 3 / 16.0, 3 / 16.0, 16 / 16.0, 13 / 16.0, 13 / 16.0 ); - rh.renderBlockCurrentBounds( x, y, z, renderer ); - - Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 ); - - FlippableIcon fpA = new FlippableIcon( firstIcon ); - FlippableIcon fpB = new FlippableIcon( secondIcon ); - - fpA.setFlip( true, false ); - fpB.setFlip( true, false ); - - Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant ); - rh.setTexture( firstOffset, firstOffset, firstOffset, firstOffset, firstIcon, fpA ); - this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); - - Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant ); - rh.setTexture( secondOffset, secondOffset, secondOffset, secondOffset, secondIcon, fpB ); - this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); - break; - case NORTH: - case SOUTH: - rh.setTexture( off, off, def, def, off, off ); - renderer.uvRotateTop = 3; - renderer.uvRotateBottom = 3; - renderer.uvRotateNorth = 1; - renderer.uvRotateSouth = 2; - renderer.uvRotateWest = 1; - renderer.setRenderBounds( 3 / 16.0, 3 / 16.0, 0, 13 / 16.0, 13 / 16.0, 16 / 16.0 ); - rh.renderBlockCurrentBounds( x, y, z, renderer ); - - Tessellator.instance.setBrightness( 15 << 20 | 15 << 4 ); - - Tessellator.instance.setColorOpaque_I( this.getCableColor().blackVariant ); - rh.setTexture( firstOffset, firstOffset, firstIcon, firstIcon, firstOffset, firstOffset ); - this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); - - Tessellator.instance.setColorOpaque_I( this.getCableColor().whiteVariant ); - rh.setTexture( secondOffset, secondOffset, secondIcon, secondIcon, secondOffset, secondOffset ); - this.renderAllFaces( (AEBaseBlock) rh.getBlock(), x, y, z, rh, renderer ); - break; - default: - break; - } - } - - renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0; - rh.setTexture( null ); + return false; } - private IIcon getDenseTexture(AEColor c) + private IIcon getDenseTexture( AEColor c ) { - switch (c) + switch ( c ) { - case Black: - return CableBusTextures.MEDense_Black.getIcon(); - case Blue: - return CableBusTextures.MEDense_Blue.getIcon(); - case Brown: - return CableBusTextures.MEDense_Brown.getIcon(); - case Cyan: - return CableBusTextures.MEDense_Cyan.getIcon(); - case Gray: - return CableBusTextures.MEDense_Gray.getIcon(); - case Green: - return CableBusTextures.MEDense_Green.getIcon(); - case LightBlue: - return CableBusTextures.MEDense_LightBlue.getIcon(); - case LightGray: - return CableBusTextures.MEDense_LightGrey.getIcon(); - case Lime: - return CableBusTextures.MEDense_Lime.getIcon(); - case Magenta: - return CableBusTextures.MEDense_Magenta.getIcon(); - case Orange: - return CableBusTextures.MEDense_Orange.getIcon(); - case Pink: - return CableBusTextures.MEDense_Pink.getIcon(); - case Purple: - return CableBusTextures.MEDense_Purple.getIcon(); - case Red: - return CableBusTextures.MEDense_Red.getIcon(); - case White: - return CableBusTextures.MEDense_White.getIcon(); - case Yellow: - return CableBusTextures.MEDense_Yellow.getIcon(); - default: + case Black: + return CableBusTextures.MEDense_Black.getIcon(); + case Blue: + return CableBusTextures.MEDense_Blue.getIcon(); + case Brown: + return CableBusTextures.MEDense_Brown.getIcon(); + case Cyan: + return CableBusTextures.MEDense_Cyan.getIcon(); + case Gray: + return CableBusTextures.MEDense_Gray.getIcon(); + case Green: + return CableBusTextures.MEDense_Green.getIcon(); + case LightBlue: + return CableBusTextures.MEDense_LightBlue.getIcon(); + case LightGray: + return CableBusTextures.MEDense_LightGrey.getIcon(); + case Lime: + return CableBusTextures.MEDense_Lime.getIcon(); + case Magenta: + return CableBusTextures.MEDense_Magenta.getIcon(); + case Orange: + return CableBusTextures.MEDense_Orange.getIcon(); + case Pink: + return CableBusTextures.MEDense_Pink.getIcon(); + case Purple: + return CableBusTextures.MEDense_Purple.getIcon(); + case Red: + return CableBusTextures.MEDense_Red.getIcon(); + case White: + return CableBusTextures.MEDense_White.getIcon(); + case Yellow: + return CableBusTextures.MEDense_Yellow.getIcon(); + default: } return this.is.getIconIndex(); } + + private boolean isDense( ForgeDirection of ) + { + TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + of.offsetX, this.tile.yCoord + of.offsetY, this.tile.zCoord + of.offsetZ ); + if ( te instanceof IGridHost ) + { + AECableType t = ( (IGridHost) te ).getCableConnectionType( of.getOpposite() ); + return t == AECableType.DENSE; + } + return false; + } + + @MENetworkEventSubscribe + public void channelUpdated( MENetworkChannelsChanged c ) + { + this.getHost().markForUpdate(); + } + + @MENetworkEventSubscribe + public void powerRender( MENetworkPowerStatusChange c ) + { + this.getHost().markForUpdate(); + } } diff --git a/src/main/java/appeng/parts/networking/PartQuartzFiber.java b/src/main/java/appeng/parts/networking/PartQuartzFiber.java index c5e2ba065..6ae77833b 100644 --- a/src/main/java/appeng/parts/networking/PartQuartzFiber.java +++ b/src/main/java/appeng/parts/networking/PartQuartzFiber.java @@ -53,7 +53,7 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", this.proxy.getMachineRepresentation(), true ); public PartQuartzFiber(ItemStack is) { - super( PartQuartzFiber.class, is ); + super( is ); this.proxy.setIdlePowerUsage( 0 ); this.proxy.setFlags( GridFlags.CANNOT_CARRY ); this.outerProxy.setIdlePowerUsage( 0 ); diff --git a/src/main/java/appeng/parts/p2p/PartP2PIC2Power.java b/src/main/java/appeng/parts/p2p/PartP2PIC2Power.java index 226331037..5b07e15d3 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PIC2Power.java +++ b/src/main/java/appeng/parts/p2p/PartP2PIC2Power.java @@ -31,9 +31,6 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import appeng.api.config.PowerUnits; -import appeng.api.config.TunnelType; -import appeng.core.AppEng; -import appeng.integration.IntegrationType; import appeng.me.GridAccessException; import appeng.me.cache.helpers.TunnelCollection; import appeng.transformer.annotations.Integration.Interface; @@ -45,17 +42,8 @@ import appeng.util.Platform; public class PartP2PIC2Power extends PartP2PTunnel implements ic2.api.energy.tile.IEnergySink, ic2.api.energy.tile.IEnergySource { - @Override - public TunnelType getTunnelType() - { - return TunnelType.IC2_POWER; - } - public PartP2PIC2Power(ItemStack is) { super( is ); - - if ( !AppEng.instance.isIntegrationEnabled( IntegrationType.IC2 ) ) - throw new RuntimeException( "IC2 Not installed!" ); } // two packet buffering... diff --git a/src/main/java/appeng/parts/p2p/PartP2PItems.java b/src/main/java/appeng/parts/p2p/PartP2PItems.java index 9f90f7a44..47e338a57 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PItems.java +++ b/src/main/java/appeng/parts/p2p/PartP2PItems.java @@ -37,7 +37,6 @@ import cpw.mods.fml.relauncher.SideOnly; import buildcraft.api.transport.IPipeConnection; import buildcraft.api.transport.IPipeTile.PipeType; -import appeng.api.config.TunnelType; import appeng.api.networking.IGridNode; import appeng.api.networking.events.MENetworkBootingStatusChange; import appeng.api.networking.events.MENetworkChannelsChanged; @@ -64,12 +63,6 @@ import appeng.util.inv.WrapperMCISidedInventory; public class PartP2PItems extends PartP2PTunnel implements IPipeConnection, ISidedInventory, IGridTickable { - @Override - public TunnelType getTunnelType() - { - return TunnelType.ITEM; - } - public PartP2PItems(ItemStack is) { super( is ); } diff --git a/src/main/java/appeng/parts/p2p/PartP2PLight.java b/src/main/java/appeng/parts/p2p/PartP2PLight.java index ca2e204d9..83f9e87ec 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PLight.java +++ b/src/main/java/appeng/parts/p2p/PartP2PLight.java @@ -32,7 +32,6 @@ import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import appeng.api.config.TunnelType; import appeng.api.networking.IGridNode; import appeng.api.networking.events.MENetworkChannelsChanged; import appeng.api.networking.events.MENetworkPowerStatusChange; @@ -49,12 +48,6 @@ public class PartP2PLight extends PartP2PTunnel implements IGridTi super( is ); } - @Override - public TunnelType getTunnelType() - { - return TunnelType.LIGHT; - } - int lastValue = 0; float opacity = -1; diff --git a/src/main/java/appeng/parts/p2p/PartP2PLiquids.java b/src/main/java/appeng/parts/p2p/PartP2PLiquids.java index 6f00803e6..566f9de37 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PLiquids.java +++ b/src/main/java/appeng/parts/p2p/PartP2PLiquids.java @@ -36,7 +36,6 @@ import net.minecraftforge.fluids.IFluidHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import appeng.api.config.TunnelType; import appeng.me.GridAccessException; public class PartP2PLiquids extends PartP2PTunnel implements IFluidHandler @@ -45,12 +44,6 @@ public class PartP2PLiquids extends PartP2PTunnel implements IFl private final static FluidTankInfo[] ACTIVE_TANK = new FluidTankInfo[] { new FluidTankInfo( null, 10000 ) }; private final static FluidTankInfo[] INACTIVE_TANK = new FluidTankInfo[] { new FluidTankInfo( null, 0 ) }; - @Override - public TunnelType getTunnelType() - { - return TunnelType.FLUID; - } - public PartP2PLiquids(ItemStack is) { super( is ); } diff --git a/src/main/java/appeng/parts/p2p/PartP2PRFPower.java b/src/main/java/appeng/parts/p2p/PartP2PRFPower.java index 993ae5642..83cdf02c6 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PRFPower.java +++ b/src/main/java/appeng/parts/p2p/PartP2PRFPower.java @@ -33,9 +33,6 @@ import cpw.mods.fml.relauncher.SideOnly; import cofh.api.energy.IEnergyReceiver; import appeng.api.config.PowerUnits; -import appeng.api.config.TunnelType; -import appeng.core.AppEng; -import appeng.integration.IntegrationType; import appeng.integration.modules.helpers.NullRFHandler; import appeng.me.GridAccessException; import appeng.transformer.annotations.Integration.Interface; @@ -57,17 +54,6 @@ public class PartP2PRFPower extends PartP2PTunnel implements IEn public PartP2PRFPower( ItemStack is ) { super( is ); - - if ( !AppEng.instance.isIntegrationEnabled( IntegrationType.RF ) ) - { - throw new RuntimeException( "RF Not installed!" ); - } - } - - @Override - public TunnelType getTunnelType() - { - return TunnelType.RF_POWER; } @Override diff --git a/src/main/java/appeng/parts/p2p/PartP2PRedstone.java b/src/main/java/appeng/parts/p2p/PartP2PRedstone.java index 35d181911..ed135abac 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PRedstone.java +++ b/src/main/java/appeng/parts/p2p/PartP2PRedstone.java @@ -29,7 +29,6 @@ import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import appeng.api.config.TunnelType; import appeng.api.networking.events.MENetworkBootingStatusChange; import appeng.api.networking.events.MENetworkChannelsChanged; import appeng.api.networking.events.MENetworkEventSubscribe; @@ -40,12 +39,6 @@ import appeng.util.Platform; public class PartP2PRedstone extends PartP2PTunnel { - @Override - public TunnelType getTunnelType() - { - return TunnelType.REDSTONE; - } - public PartP2PRedstone(ItemStack is) { super( is ); } diff --git a/src/main/java/appeng/parts/p2p/PartP2PTunnel.java b/src/main/java/appeng/parts/p2p/PartP2PTunnel.java index bf79f2a4c..5086efbaa 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PTunnel.java +++ b/src/main/java/appeng/parts/p2p/PartP2PTunnel.java @@ -18,11 +18,14 @@ package appeng.parts.p2p; + import java.util.ArrayList; import java.util.Collection; +import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; @@ -32,11 +35,14 @@ import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import com.google.common.base.Optional; + import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.config.PowerMultiplier; import appeng.api.config.PowerUnits; import appeng.api.config.TunnelType; +import appeng.api.definitions.IParts; import appeng.api.implementations.items.IMemoryCard; import appeng.api.implementations.items.MemoryCardMessages; import appeng.api.parts.IPart; @@ -52,17 +58,158 @@ import appeng.me.cache.helpers.TunnelCollection; import appeng.parts.PartBasicState; import appeng.util.Platform; -public class PartP2PTunnel extends PartBasicState -{ +public abstract class PartP2PTunnel extends PartBasicState +{ + private final TunnelCollection type = new TunnelCollection( null, this.getClass() ); public boolean output; public long freq; - final TunnelCollection type = new TunnelCollection( null, this.getClass() ); - public PartP2PTunnel(ItemStack is) { - super( PartP2PTunnel.class, is ); - if ( this.getClass() == PartP2PTunnel.class ) - throw new RuntimeException( "Don't construct the root tunnel!" ); + public PartP2PTunnel( ItemStack is ) + { + super( is ); + } + + public TunnelCollection getCollection( Collection collection, Class c ) + { + if ( this.type.matches( c ) ) + { + this.type.setSource( collection ); + return this.type; + } + + return null; + } + + public T getInput() + { + if ( this.freq == 0 ) + return null; + + PartP2PTunnel tunnel; + try + { + tunnel = this.proxy.getP2P().getInput( this.freq ); + if ( this.getClass().isInstance( tunnel ) ) + return (T) tunnel; + } + catch ( GridAccessException e ) + { + // :P + } + return null; + } + + public TunnelCollection getOutputs() throws GridAccessException + { + if ( this.proxy.isActive() ) + return (TunnelCollection) this.proxy.getP2P().getOutputs( this.freq, this.getClass() ); + return new TunnelCollection( new ArrayList(), this.getClass() ); + } + + @Override + @SideOnly( Side.CLIENT ) + public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ) + { + rh.setTexture( this.getTypeTexture() ); + + rh.setBounds( 2, 2, 14, 14, 14, 16 ); + rh.renderInventoryBox( renderer ); + + rh.setTexture( CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.BlockP2PTunnel2.getIcon(), this.is.getIconIndex(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon() ); + + rh.setBounds( 2, 2, 14, 14, 14, 16 ); + rh.renderInventoryBox( renderer ); + } + + /** + * @return If enabled it returns the icon of an AE quatz block, else vanilla quartz block icon + */ + protected IIcon getTypeTexture() + { + final Optional maybeBlock = AEApi.instance().definitions().blocks().quartz().maybeBlock(); + if ( maybeBlock.isPresent() ) + { + return maybeBlock.get().getIcon( 0, 0 ); + } + else + { + return Blocks.quartz_block.getIcon( 0, 0 ); + } + } + + @Override + @SideOnly( Side.CLIENT ) + public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ) + { + this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); + rh.setTexture( this.getTypeTexture() ); + + rh.setBounds( 2, 2, 14, 14, 14, 16 ); + rh.renderBlock( x, y, z, renderer ); + + rh.setTexture( CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.BlockP2PTunnel2.getIcon(), this.is.getIconIndex(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon() ); + + rh.setBounds( 2, 2, 14, 14, 14, 16 ); + rh.renderBlock( x, y, z, renderer ); + + rh.setBounds( 3, 3, 13, 13, 13, 14 ); + rh.renderBlock( x, y, z, renderer ); + + rh.setTexture( CableBusTextures.BlockP2PTunnel3.getIcon() ); + + rh.setBounds( 6, 5, 12, 10, 11, 13 ); + rh.renderBlock( x, y, z, renderer ); + + rh.setBounds( 5, 6, 12, 11, 10, 13 ); + rh.renderBlock( x, y, z, renderer ); + + this.renderLights( x, y, z, rh, renderer ); + } + + @Override + public ItemStack getItemStack( PartItemStack type ) + { + if ( type == PartItemStack.World || type == PartItemStack.Network || type == PartItemStack.Wrench || type == PartItemStack.Pick ) + return super.getItemStack( type ); + + final Optional maybeMEStack = AEApi.instance().definitions().parts().p2PTunnelME().maybeStack( 1 ); + if ( maybeMEStack.isPresent() ) + { + return maybeMEStack.get(); + } + + return super.getItemStack( type ); + } + + @Override + public void readFromNBT( NBTTagCompound data ) + { + super.readFromNBT( data ); + this.output = data.getBoolean( "output" ); + this.freq = data.getLong( "freq" ); + } + + @Override + public void writeToNBT( NBTTagCompound data ) + { + super.writeToNBT( data ); + data.setBoolean( "output", this.output ); + data.setLong( "freq", this.freq ); + } + + @Override + public void getBoxes( IPartCollisionHelper bch ) + { + bch.addBox( 5, 5, 12, 11, 11, 13 ); + bch.addBox( 3, 3, 13, 13, 13, 14 ); + bch.addBox( 2, 2, 14, 14, 14, 16 ); + } + + @Override + public int cableConnectionRenderTo() + { + return 1; } @Override @@ -72,23 +219,7 @@ public class PartP2PTunnel extends PartBasicState } @Override - public void writeToNBT(NBTTagCompound data) - { - super.writeToNBT( data ); - data.setBoolean( "output", this.output ); - data.setLong( "freq", this.freq ); - } - - @Override - public void readFromNBT(NBTTagCompound data) - { - super.readFromNBT( data ); - this.output = data.getBoolean( "output" ); - this.freq = data.getLong( "freq" ); - } - - @Override - public boolean onPartActivate(EntityPlayer player, Vec3 pos) + public boolean onPartActivate( EntityPlayer player, Vec3 pos ) { ItemStack is = player.inventory.getCurrentItem(); @@ -108,7 +239,7 @@ public class PartP2PTunnel extends PartBasicState { if ( newType.getItem() instanceof IPartItem ) { - IPart testPart = ((IPartItem) newType.getItem()).createPartFromItemStack( newType ); + IPart testPart = ( (IPartItem) newType.getItem() ).createPartFromItemStack( newType ); if ( testPart instanceof PartP2PTunnel ) { this.getHost().removePart( this.side, true ); @@ -125,7 +256,7 @@ public class PartP2PTunnel extends PartBasicState P2PCache p2p = newTunnel.proxy.getP2P(); p2p.updateFreq( newTunnel, freq ); } - catch (GridAccessException e) + catch ( GridAccessException e ) { // :P } @@ -144,43 +275,61 @@ public class PartP2PTunnel extends PartBasicState { ItemStack newType = null; - switch (tt) + final IParts parts = AEApi.instance().definitions().parts(); + + switch ( tt ) { - case LIGHT: - newType = AEApi.instance().parts().partP2PTunnelLight.stack( 1 ); - break; + case LIGHT: + for ( ItemStack stack : parts.p2PTunnelLight().maybeStack( 1 ).asSet() ) + { + newType = stack; + } + break; - case RF_POWER: - newType = AEApi.instance().parts().partP2PTunnelRF.stack( 1 ); - break; + case RF_POWER: + for ( ItemStack stack : parts.p2PTunnelRF().maybeStack( 1 ).asSet() ) + { + newType = stack; + } + break; - case BC_POWER: - newType = AEApi.instance().parts().partP2PTunnelMJ.stack( 1 ); - break; + case FLUID: + for ( ItemStack stack : parts.p2PTunnelLiquids().maybeStack( 1 ).asSet() ) + { + newType = stack; + } + break; - case FLUID: - newType = AEApi.instance().parts().partP2PTunnelLiquids.stack( 1 ); - break; + case IC2_POWER: + for ( ItemStack stack : parts.p2PTunnelEU().maybeStack( 1 ).asSet() ) + { + newType = stack; + } + break; - case IC2_POWER: - newType = AEApi.instance().parts().partP2PTunnelEU.stack( 1 ); - break; + case ITEM: + for ( ItemStack stack : parts.p2PTunnelItems().maybeStack( 1 ).asSet() ) + { + newType = stack; + } + break; - case ITEM: - newType = AEApi.instance().parts().partP2PTunnelItems.stack( 1 ); - break; + case ME: + for ( ItemStack stack : parts.p2PTunnelME().maybeStack( 1 ).asSet() ) + { + newType = stack; + } + break; - case ME: - newType = AEApi.instance().parts().partP2PTunnelME.stack( 1 ); - break; - - case REDSTONE: - newType = AEApi.instance().parts().partP2PTunnelRedstone.stack( 1 ); - break; - - default: - break; + case REDSTONE: + for ( ItemStack stack : parts.p2PTunnelRedstone().maybeStack( 1 ).asSet() ) + { + newType = stack; + } + break; + default: + break; } if ( newType != null && !Platform.isSameItem( newType, this.is ) ) @@ -203,7 +352,7 @@ public class PartP2PTunnel extends PartBasicState P2PCache p2p = newTunnel.proxy.getP2P(); p2p.updateFreq( newTunnel, myFreq ); } - catch (GridAccessException e) + catch ( GridAccessException e ) { // :P } @@ -217,13 +366,8 @@ public class PartP2PTunnel extends PartBasicState return false; } - public TunnelType getTunnelType() - { - return null; - } - @Override - public boolean onPartShiftActivate(EntityPlayer player, Vec3 pos) + public boolean onPartShiftActivate( EntityPlayer player, Vec3 pos ) { ItemStack is = player.inventory.getCurrentItem(); if ( is != null && is.getItem() instanceof IMemoryCard ) @@ -242,7 +386,7 @@ public class PartP2PTunnel extends PartBasicState { this.proxy.getP2P().updateFreq( this, newFreq ); } - catch (GridAccessException e) + catch ( GridAccessException e ) { // :P } @@ -266,116 +410,19 @@ public class PartP2PTunnel extends PartBasicState { } - @Override - public ItemStack getItemStack(PartItemStack type) - { - if ( type == PartItemStack.World || type == PartItemStack.Network || type == PartItemStack.Wrench || type == PartItemStack.Pick ) - return super.getItemStack( type ); - - return AEApi.instance().parts().partP2PTunnelME.stack( 1 ); - } - - public TunnelCollection getCollection(Collection collection, Class c) - { - if ( this.type.matches( c ) ) - { - this.type.setSource( collection ); - return this.type; - } - - return null; - } - - public T getInput() - { - if ( this.freq == 0 ) - return null; - - PartP2PTunnel tunnel; - try - { - tunnel = this.proxy.getP2P().getInput( this.freq ); - if ( this.getClass().isInstance( tunnel ) ) - return (T) tunnel; - } - catch (GridAccessException e) - { - // :P - } - return null; - } - - public TunnelCollection getOutputs() throws GridAccessException - { - if ( this.proxy.isActive() ) - return (TunnelCollection) this.proxy.getP2P().getOutputs( this.freq, this.getClass() ); - return new TunnelCollection( new ArrayList(), this.getClass() ); - } - public void onTunnelNetworkChange() { } @Override - @SideOnly(Side.CLIENT) - public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) - { - rh.setTexture( this.getTypeTexture() ); - - rh.setBounds( 2, 2, 14, 14, 14, 16 ); - rh.renderInventoryBox( renderer ); - - rh.setTexture( CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.BlockP2PTunnel2.getIcon(), - this.is.getIconIndex(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon() ); - - rh.setBounds( 2, 2, 14, 14, 14, 16 ); - rh.renderInventoryBox( renderer ); - } - - protected IIcon getTypeTexture() - { - return AEApi.instance().blocks().blockQuartz.block().getIcon( 0, 0 ); - } - - @Override - @SideOnly(Side.CLIENT) - public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer) - { - this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); - rh.setTexture( this.getTypeTexture() ); - - rh.setBounds( 2, 2, 14, 14, 14, 16 ); - rh.renderBlock( x, y, z, renderer ); - - rh.setTexture( CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.BlockP2PTunnel2.getIcon(), - this.is.getIconIndex(), CableBusTextures.PartTunnelSides.getIcon(), CableBusTextures.PartTunnelSides.getIcon() ); - - rh.setBounds( 2, 2, 14, 14, 14, 16 ); - rh.renderBlock( x, y, z, renderer ); - - rh.setBounds( 3, 3, 13, 13, 13, 14 ); - rh.renderBlock( x, y, z, renderer ); - - rh.setTexture( CableBusTextures.BlockP2PTunnel3.getIcon() ); - - rh.setBounds( 6, 5, 12, 10, 11, 13 ); - rh.renderBlock( x, y, z, renderer ); - - rh.setBounds( 5, 6, 12, 11, 10, 13 ); - rh.renderBlock( x, y, z, renderer ); - - this.renderLights( x, y, z, rh, renderer ); - } - - @Override - @SideOnly(Side.CLIENT) + @SideOnly( Side.CLIENT ) public IIcon getBreakingTexture() { return CableBusTextures.BlockP2PTunnel2.getIcon(); } - protected void QueueTunnelDrain(PowerUnits unit, double f) + protected void QueueTunnelDrain( PowerUnits unit, double f ) { double ae_to_tax = unit.convertTo( PowerUnits.AE, f * AEConfig.TUNNEL_POWER_LOSS ); @@ -383,24 +430,9 @@ public class PartP2PTunnel extends PartBasicState { this.proxy.getEnergy().extractAEPower( ae_to_tax, Actionable.MODULATE, PowerMultiplier.ONE ); } - catch (GridAccessException e) + catch ( GridAccessException e ) { // :P } } - - @Override - public void getBoxes(IPartCollisionHelper bch) - { - bch.addBox( 5, 5, 12, 11, 11, 13 ); - bch.addBox( 3, 3, 13, 13, 13, 14 ); - bch.addBox( 2, 2, 14, 14, 14, 16 ); - } - - @Override - public int cableConnectionRenderTo() - { - return 1; - } - } diff --git a/src/main/java/appeng/parts/p2p/PartP2PTunnelME.java b/src/main/java/appeng/parts/p2p/PartP2PTunnelME.java index a6f9aef61..2f9f9deae 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PTunnelME.java +++ b/src/main/java/appeng/parts/p2p/PartP2PTunnelME.java @@ -30,7 +30,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import appeng.api.AEApi; -import appeng.api.config.TunnelType; import appeng.api.exceptions.FailedConnection; import appeng.api.networking.GridFlags; import appeng.api.networking.IGridNode; @@ -51,12 +50,6 @@ import appeng.me.helpers.AENetworkProxy; public class PartP2PTunnelME extends PartP2PTunnel implements IGridTickable { - @Override - public TunnelType getTunnelType() - { - return TunnelType.ME; - } - final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", null, true ); public final Connections connection = new Connections( this ); diff --git a/src/main/java/appeng/parts/reporting/PartConversionMonitor.java b/src/main/java/appeng/parts/reporting/PartConversionMonitor.java index de99385a3..bd2aeccb7 100644 --- a/src/main/java/appeng/parts/reporting/PartConversionMonitor.java +++ b/src/main/java/appeng/parts/reporting/PartConversionMonitor.java @@ -33,16 +33,20 @@ import appeng.api.networking.security.PlayerSource; import appeng.api.storage.IMEMonitor; import appeng.api.storage.data.IAEItemStack; import appeng.client.texture.CableBusTextures; +import appeng.helpers.Reflected; import appeng.me.GridAccessException; import appeng.util.InventoryAdaptor; import appeng.util.Platform; import appeng.util.item.AEItemStack; + public class PartConversionMonitor extends PartStorageMonitor { + @Reflected + public PartConversionMonitor( ItemStack is ) + { + super( is ); - public PartConversionMonitor(ItemStack is) { - super( PartConversionMonitor.class, is ); this.frontBright = CableBusTextures.PartConversionMonitor_Bright; this.frontColored = CableBusTextures.PartConversionMonitor_Colored; this.frontDark = CableBusTextures.PartConversionMonitor_Dark; @@ -50,7 +54,7 @@ public class PartConversionMonitor extends PartStorageMonitor } @Override - public boolean onPartShiftActivate(EntityPlayer player, Vec3 pos) + public boolean onPartShiftActivate( EntityPlayer player, Vec3 pos ) { if ( Platform.isClient() ) return true; @@ -67,7 +71,7 @@ public class PartConversionMonitor extends PartStorageMonitor if ( item == null && this.getDisplayed() != null ) { ModeB = true; - item = ((IAEItemStack) this.getDisplayed()).getItemStack(); + item = ( (IAEItemStack) this.getDisplayed() ).getItemStack(); } if ( item != null ) @@ -83,7 +87,7 @@ public class PartConversionMonitor extends PartStorageMonitor if ( ModeB ) { - for (int x = 0; x < player.inventory.getSizeInventory(); x++) + for ( int x = 0; x < player.inventory.getSizeInventory(); x++ ) { ItemStack targetStack = player.inventory.getStackInSlot( x ); if ( input.equals( targetStack ) ) @@ -101,7 +105,7 @@ public class PartConversionMonitor extends PartStorageMonitor player.inventory.setInventorySlotContents( player.inventory.currentItem, failedToInsert == null ? null : failedToInsert.getItemStack() ); } } - catch (GridAccessException e) + catch ( GridAccessException e ) { // :P } @@ -110,7 +114,7 @@ public class PartConversionMonitor extends PartStorageMonitor } @Override - protected void extractItem(EntityPlayer player) + protected void extractItem( EntityPlayer player ) { IAEItemStack input = (IAEItemStack) this.getDisplayed(); if ( input != null ) @@ -143,11 +147,10 @@ public class PartConversionMonitor extends PartStorageMonitor player.openContainer.detectAndSendChanges(); } } - catch (GridAccessException e) + catch ( GridAccessException e ) { // :P } } } - } diff --git a/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java b/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java index f43b2d361..e2eb541f7 100644 --- a/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java @@ -18,6 +18,7 @@ package appeng.parts.reporting; + import java.util.List; import net.minecraft.entity.player.EntityPlayer; @@ -27,44 +28,48 @@ import net.minecraft.nbt.NBTTagCompound; import appeng.client.texture.CableBusTextures; import appeng.core.sync.GuiBridge; +import appeng.helpers.Reflected; import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.InvOperation; + public class PartCraftingTerminal extends PartTerminal { + private final AppEngInternalInventory craftingGrid = new AppEngInternalInventory( this, 9 ); - final AppEngInternalInventory craftingGrid = new AppEngInternalInventory( this, 9 ); - - @Override - public void writeToNBT(NBTTagCompound data) + @Reflected + public PartCraftingTerminal( ItemStack is ) { - super.writeToNBT( data ); - this.craftingGrid.writeToNBT( data, "craftingGrid" ); + super( is ); + + this.frontBright = CableBusTextures.PartCraftingTerm_Bright; + this.frontColored = CableBusTextures.PartCraftingTerm_Colored; + this.frontDark = CableBusTextures.PartCraftingTerm_Dark; + // frontSolid = CableBusTextures.PartCraftingTerm_Solid; } @Override - public void readFromNBT(NBTTagCompound data) + public void getDrops( List drops, boolean wrenched ) + { + super.getDrops( drops, wrenched ); + + for ( ItemStack is : this.craftingGrid ) + if ( is != null ) + drops.add( is ); + } + + @Override + public void readFromNBT( NBTTagCompound data ) { super.readFromNBT( data ); this.craftingGrid.readFromNBT( data, "craftingGrid" ); } @Override - public void getDrops(List drops, boolean wrenched) + public void writeToNBT( NBTTagCompound data ) { - super.getDrops( drops, wrenched ); - - for (ItemStack is : this.craftingGrid) - if ( is != null ) - drops.add( is ); - } - - public PartCraftingTerminal(ItemStack is) { - super( PartCraftingTerminal.class, is ); - this.frontBright = CableBusTextures.PartCraftingTerm_Bright; - this.frontColored = CableBusTextures.PartCraftingTerm_Colored; - this.frontDark = CableBusTextures.PartCraftingTerm_Dark; - // frontSolid = CableBusTextures.PartCraftingTerm_Solid; + super.writeToNBT( data ); + this.craftingGrid.writeToNBT( data, "craftingGrid" ); } @Override @@ -80,23 +85,22 @@ public class PartCraftingTerminal extends PartTerminal z = this.tile.zCoord; } - if( GuiBridge.GUI_CRAFTING_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.side, p ) ) + if ( GuiBridge.GUI_CRAFTING_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.side, p ) ) return GuiBridge.GUI_CRAFTING_TERMINAL; return GuiBridge.GUI_ME; } @Override - public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) + public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack ) { this.host.markForSave(); } @Override - public IInventory getInventoryByName(String name) + public IInventory getInventoryByName( String name ) { if ( name.equals( "crafting" ) ) return this.craftingGrid; return super.getInventoryByName( name ); } - } diff --git a/src/main/java/appeng/parts/reporting/PartDarkMonitor.java b/src/main/java/appeng/parts/reporting/PartDarkMonitor.java index 2726cb339..8d62ae2e6 100644 --- a/src/main/java/appeng/parts/reporting/PartDarkMonitor.java +++ b/src/main/java/appeng/parts/reporting/PartDarkMonitor.java @@ -18,6 +18,7 @@ package appeng.parts.reporting; + import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.item.ItemStack; @@ -29,22 +30,22 @@ import cpw.mods.fml.relauncher.SideOnly; import appeng.api.parts.IPartRenderHelper; import appeng.client.texture.CableBusTextures; + public class PartDarkMonitor extends PartMonitor { - - public PartDarkMonitor(ItemStack is) { - super( PartDarkMonitor.class, is, false ); + public PartDarkMonitor( ItemStack is ) + { + super( is, false ); this.notLightSource = false; } @Override - @SideOnly(Side.CLIENT) - public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) + @SideOnly( Side.CLIENT ) + public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ) { rh.setBounds( 2, 2, 14, 14, 14, 16 ); - rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), - this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); + rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); rh.renderInventoryBox( renderer ); rh.setInvColor( this.getColor().mediumVariant ); @@ -55,11 +56,10 @@ public class PartDarkMonitor extends PartMonitor } @Override - @SideOnly(Side.CLIENT) - public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer) + @SideOnly( Side.CLIENT ) + public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ) { - rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), - this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); + rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); rh.setBounds( 2, 2, 14, 14, 14, 16 ); rh.renderBlock( x, y, z, renderer ); @@ -76,5 +76,4 @@ public class PartDarkMonitor extends PartMonitor rh.setBounds( 4, 4, 13, 12, 12, 14 ); rh.renderBlock( x, y, z, renderer ); } - } diff --git a/src/main/java/appeng/parts/reporting/PartInterfaceTerminal.java b/src/main/java/appeng/parts/reporting/PartInterfaceTerminal.java index 67032f17d..e57dd7d78 100644 --- a/src/main/java/appeng/parts/reporting/PartInterfaceTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartInterfaceTerminal.java @@ -18,6 +18,7 @@ package appeng.parts.reporting; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.Vec3; @@ -26,18 +27,20 @@ import appeng.client.texture.CableBusTextures; import appeng.core.sync.GuiBridge; import appeng.util.Platform; + public class PartInterfaceTerminal extends PartMonitor { + public PartInterfaceTerminal( ItemStack is ) + { + super( is, true ); - public PartInterfaceTerminal(ItemStack is) { - super( PartInterfaceTerminal.class, is, true ); this.frontBright = CableBusTextures.PartInterfaceTerm_Bright; this.frontColored = CableBusTextures.PartInterfaceTerm_Colored; this.frontDark = CableBusTextures.PartInterfaceTerm_Dark; } @Override - public boolean onPartActivate(EntityPlayer player, Vec3 pos) + public boolean onPartActivate( EntityPlayer player, Vec3 pos ) { if ( !super.onPartActivate( player, pos ) ) { diff --git a/src/main/java/appeng/parts/reporting/PartMonitor.java b/src/main/java/appeng/parts/reporting/PartMonitor.java index de8466d72..1ff5fc5b8 100644 --- a/src/main/java/appeng/parts/reporting/PartMonitor.java +++ b/src/main/java/appeng/parts/reporting/PartMonitor.java @@ -221,13 +221,13 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann return false; } } - + public PartMonitor(ItemStack is) { - this( PartMonitor.class, is, false ); + this( is, false ); } - protected PartMonitor(Class c, ItemStack is, boolean requireChannel) { - super( c, is ); + protected PartMonitor(ItemStack is, boolean requireChannel) { + super( is ); if ( requireChannel ) { diff --git a/src/main/java/appeng/parts/reporting/PartPatternTerminal.java b/src/main/java/appeng/parts/reporting/PartPatternTerminal.java index 8790baf3f..161339438 100644 --- a/src/main/java/appeng/parts/reporting/PartPatternTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartPatternTerminal.java @@ -18,6 +18,7 @@ package appeng.parts.reporting; + import java.util.List; import net.minecraft.entity.player.EntityPlayer; @@ -30,20 +31,39 @@ import appeng.api.networking.crafting.ICraftingPatternDetails; import appeng.api.storage.data.IAEItemStack; import appeng.client.texture.CableBusTextures; import appeng.core.sync.GuiBridge; +import appeng.helpers.Reflected; import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.InvOperation; + public class PartPatternTerminal extends PartTerminal { - - final AppEngInternalInventory crafting = new AppEngInternalInventory( this, 9 ); - final AppEngInternalInventory output = new AppEngInternalInventory( this, 3 ); - final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 ); + private final AppEngInternalInventory crafting = new AppEngInternalInventory( this, 9 ); + private final AppEngInternalInventory output = new AppEngInternalInventory( this, 3 ); + private final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 ); private boolean craftingMode = true; + @Reflected + public PartPatternTerminal( ItemStack is ) + { + super( is ); + + this.frontBright = CableBusTextures.PartPatternTerm_Bright; + this.frontColored = CableBusTextures.PartPatternTerm_Colored; + this.frontDark = CableBusTextures.PartPatternTerm_Dark; + } + @Override - public void writeToNBT(NBTTagCompound data) + public void getDrops( List drops, boolean wrenched ) + { + for ( ItemStack is : this.pattern ) + if ( is != null ) + drops.add( is ); + } + + @Override + public void writeToNBT( NBTTagCompound data ) { super.writeToNBT( data ); data.setBoolean( "craftingMode", this.craftingMode ); @@ -53,7 +73,7 @@ public class PartPatternTerminal extends PartTerminal } @Override - public void readFromNBT(NBTTagCompound data) + public void readFromNBT( NBTTagCompound data ) { super.readFromNBT( data ); this.setCraftingRecipe( data.getBoolean( "craftingMode" ) ); @@ -62,21 +82,6 @@ public class PartPatternTerminal extends PartTerminal this.crafting.readFromNBT( data, "craftingGrid" ); } - @Override - public void getDrops(List drops, boolean wrenched) - { - for (ItemStack is : this.pattern) - if ( is != null ) - drops.add( is ); - } - - public PartPatternTerminal(ItemStack is) { - super( PartPatternTerminal.class, is ); - this.frontBright = CableBusTextures.PartPatternTerm_Bright; - this.frontColored = CableBusTextures.PartPatternTerm_Colored; - this.frontDark = CableBusTextures.PartPatternTerm_Dark; - } - @Override public GuiBridge getGui( EntityPlayer p ) { @@ -90,28 +95,13 @@ public class PartPatternTerminal extends PartTerminal z = this.tile.zCoord; } - if( GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.side, p ) ) + if ( GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.side, p ) ) return GuiBridge.GUI_PATTERN_TERMINAL; return GuiBridge.GUI_ME; } @Override - public IInventory getInventoryByName(String name) - { - if ( name.equals( "crafting" ) ) - return this.crafting; - - if ( name.equals( "output" ) ) - return this.output; - - if ( name.equals( "pattern" ) ) - return this.pattern; - - return super.getInventoryByName( name ); - } - - @Override - public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) + public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack ) { if ( inv == this.pattern && slot == 1 ) { @@ -124,13 +114,13 @@ public class PartPatternTerminal extends PartTerminal { this.setCraftingRecipe( details.isCraftable() ); - for (int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++) + for ( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ ) { IAEItemStack item = details.getInputs()[x]; this.crafting.setInventorySlotContents( x, item == null ? null : item.getItemStack() ); } - for (int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++) + for ( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ ) { IAEItemStack item = details.getOutputs()[x]; this.output.setInventorySlotContents( x, item == null ? null : item.getItemStack() ); @@ -146,22 +136,11 @@ public class PartPatternTerminal extends PartTerminal this.host.markForSave(); } - public boolean isCraftingRecipe() - { - return this.craftingMode; - } - - public void setCraftingRecipe(boolean craftingMode) - { - this.craftingMode = craftingMode; - this.fixCraftingRecipes(); - } - private void fixCraftingRecipes() { if ( this.craftingMode ) { - for (int x = 0; x < this.crafting.getSizeInventory(); x++) + for ( int x = 0; x < this.crafting.getSizeInventory(); x++ ) { ItemStack is = this.crafting.getStackInSlot( x ); if ( is != null ) @@ -169,4 +148,30 @@ public class PartPatternTerminal extends PartTerminal } } } + + public boolean isCraftingRecipe() + { + return this.craftingMode; + } + + public void setCraftingRecipe( boolean craftingMode ) + { + this.craftingMode = craftingMode; + this.fixCraftingRecipes(); + } + + @Override + public IInventory getInventoryByName( String name ) + { + if ( name.equals( "crafting" ) ) + return this.crafting; + + if ( name.equals( "output" ) ) + return this.output; + + if ( name.equals( "pattern" ) ) + return this.pattern; + + return super.getInventoryByName( name ); + } } diff --git a/src/main/java/appeng/parts/reporting/PartSemiDarkMonitor.java b/src/main/java/appeng/parts/reporting/PartSemiDarkMonitor.java index abb9f9d06..ce0903a7c 100644 --- a/src/main/java/appeng/parts/reporting/PartSemiDarkMonitor.java +++ b/src/main/java/appeng/parts/reporting/PartSemiDarkMonitor.java @@ -18,6 +18,7 @@ package appeng.parts.reporting; + import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.item.ItemStack; @@ -29,28 +30,28 @@ import cpw.mods.fml.relauncher.SideOnly; import appeng.api.parts.IPartRenderHelper; import appeng.client.texture.CableBusTextures; + public class PartSemiDarkMonitor extends PartMonitor { + public PartSemiDarkMonitor( ItemStack is ) + { + super( is, false ); - public PartSemiDarkMonitor(ItemStack is) { - super( PartSemiDarkMonitor.class, is,false ); this.notLightSource = false; } @Override - @SideOnly(Side.CLIENT) - public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) + @SideOnly( Side.CLIENT ) + public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer ) { rh.setBounds( 2, 2, 14, 14, 14, 16 ); - rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), - this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); + rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); rh.renderInventoryBox( renderer ); int light = this.getColor().whiteVariant; int dark = this.getColor().mediumVariant; - rh.setInvColor( (((((light >> 16) & 0xff) + ((dark >> 16) & 0xff)) / 2) << 16) | (((((light >> 8) & 0xff) + ((dark >> 8) & 0xff)) / 2) << 8) - | ((((light) & 0xff) + ((dark) & 0xff)) / 2) ); + rh.setInvColor( ( ( ( ( ( light >> 16 ) & 0xff ) + ( ( dark >> 16 ) & 0xff ) ) / 2 ) << 16 ) | ( ( ( ( ( light >> 8 ) & 0xff ) + ( ( dark >> 8 ) & 0xff ) ) / 2 ) << 8 ) | ( ( ( ( light ) & 0xff ) + ( ( dark ) & 0xff ) ) / 2 ) ); rh.renderInventoryFace( this.frontBright.getIcon(), ForgeDirection.SOUTH, renderer ); rh.setBounds( 4, 4, 13, 12, 12, 14 ); @@ -58,11 +59,10 @@ public class PartSemiDarkMonitor extends PartMonitor } @Override - @SideOnly(Side.CLIENT) - public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer) + @SideOnly( Side.CLIENT ) + public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ) { - rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), - this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); + rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); rh.setBounds( 2, 2, 14, 14, 14, 16 ); rh.renderBlock( x, y, z, renderer ); @@ -75,12 +75,10 @@ public class PartSemiDarkMonitor extends PartMonitor int light = this.getColor().whiteVariant; int dark = this.getColor().mediumVariant; - Tessellator.instance.setColorOpaque( (((light >> 16) & 0xff) + ((dark >> 16) & 0xff)) / 2, (((light >> 8) & 0xff) + ((dark >> 8) & 0xff)) / 2, - (((light) & 0xff) + ((dark) & 0xff)) / 2 ); + Tessellator.instance.setColorOpaque( ( ( ( light >> 16 ) & 0xff ) + ( ( dark >> 16 ) & 0xff ) ) / 2, ( ( ( light >> 8 ) & 0xff ) + ( ( dark >> 8 ) & 0xff ) ) / 2, ( ( ( light ) & 0xff ) + ( ( dark ) & 0xff ) ) / 2 ); rh.renderFace( x, y, z, this.frontBright.getIcon(), ForgeDirection.SOUTH, renderer ); rh.setBounds( 4, 4, 13, 12, 12, 14 ); rh.renderBlock( x, y, z, renderer ); } - } diff --git a/src/main/java/appeng/parts/reporting/PartStorageMonitor.java b/src/main/java/appeng/parts/reporting/PartStorageMonitor.java index efca8d6f0..8a17b45ba 100644 --- a/src/main/java/appeng/parts/reporting/PartStorageMonitor.java +++ b/src/main/java/appeng/parts/reporting/PartStorageMonitor.java @@ -57,18 +57,36 @@ import appeng.client.ClientHelper; import appeng.client.texture.CableBusTextures; import appeng.core.AELog; import appeng.core.localization.PlayerMessages; +import appeng.helpers.Reflected; import appeng.me.GridAccessException; import appeng.util.Platform; import appeng.util.item.AEItemStack; + public class PartStorageMonitor extends PartMonitor implements IPartStorageMonitor, IStackWatcherHost { IAEItemStack configuredItem; boolean isLocked; + IStackWatcher myWatcher; + @SideOnly( Side.CLIENT ) + private boolean updateList; + @SideOnly( Side.CLIENT ) + private Integer dspList; + + @Reflected + public PartStorageMonitor( ItemStack is ) + { + super( is, true ); + + this.frontBright = CableBusTextures.PartStorageMonitor_Bright; + this.frontColored = CableBusTextures.PartStorageMonitor_Colored; + this.frontDark = CableBusTextures.PartStorageMonitor_Dark; + // frontSolid = CableBusTextures.PartStorageMonitor_Solid; + } @Override - public void writeToNBT(NBTTagCompound data) + public void writeToNBT( NBTTagCompound data ) { super.writeToNBT( data ); @@ -82,7 +100,7 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit } @Override - public void readFromNBT(NBTTagCompound data) + public void readFromNBT( NBTTagCompound data ) { super.readFromNBT( data ); @@ -93,7 +111,39 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit } @Override - public void writeToStream(ByteBuf data) throws IOException + public boolean onPartActivate( EntityPlayer player, Vec3 pos ) + { + if ( Platform.isClient() ) + return true; + + if ( !this.proxy.isActive() ) + return false; + + if ( !Platform.hasPermissions( this.getLocation(), player ) ) + return false; + + TileEntity te = this.tile; + ItemStack eq = player.getCurrentEquippedItem(); + if ( Platform.isWrench( player, eq, te.xCoord, te.yCoord, te.zCoord ) ) + { + this.isLocked = !this.isLocked; + player.addChatMessage( ( this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked ).get() ); + this.getHost().markForUpdate(); + } + else if ( !this.isLocked ) + { + this.configuredItem = AEItemStack.create( eq ); + this.configureWatchers(); + this.getHost().markForUpdate(); + } + else + this.extractItem( player ); + + return true; + } + + @Override + public void writeToStream( ByteBuf data ) throws IOException { super.writeToStream( data ); @@ -105,7 +155,7 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit } @Override - public boolean readFromStream(ByteBuf data) throws IOException + public boolean readFromStream( ByteBuf data ) throws IOException { boolean stuff = super.readFromStream( data ); @@ -122,69 +172,47 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit return stuff; } - @Override - public boolean onPartActivate(EntityPlayer player, Vec3 pos) + // update the system... + public void configureWatchers() { - if ( Platform.isClient() ) - return true; + if ( this.myWatcher != null ) + this.myWatcher.clear(); - if ( !this.proxy.isActive() ) - return false; - - if ( !Platform.hasPermissions( this.getLocation(), player ) ) - return false; - - TileEntity te = this.tile; - ItemStack eq = player.getCurrentEquippedItem(); - if ( Platform.isWrench( player, eq, te.xCoord, te.yCoord, te.zCoord ) ) + try { - this.isLocked = !this.isLocked; - player.addChatMessage( (this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked).get() ); - this.getHost().markForUpdate(); + if ( this.configuredItem != null ) + { + if ( this.myWatcher != null ) + this.myWatcher.add( this.configuredItem ); + + this.updateReportingValue( this.proxy.getStorage().getItemInventory() ); + } } - else if ( !this.isLocked ) + catch ( GridAccessException e ) { - this.configuredItem = AEItemStack.create( eq ); - this.configureWatchers(); - this.getHost().markForUpdate(); + // >.> } - else - this.extractItem( player ); - - return true; } - protected void extractItem(EntityPlayer player) + protected void extractItem( EntityPlayer player ) { } - protected PartStorageMonitor(Class myClass, ItemStack is) { - super( myClass, is, true ); - } - - public PartStorageMonitor(ItemStack is) { - super( PartStorageMonitor.class, is, true ); - this.frontBright = CableBusTextures.PartStorageMonitor_Bright; - this.frontColored = CableBusTextures.PartStorageMonitor_Colored; - this.frontDark = CableBusTextures.PartStorageMonitor_Dark; - // frontSolid = CableBusTextures.PartStorageMonitor_Solid; - } - - @Override - public boolean requireDynamicRender() + private void updateReportingValue( IMEMonitor itemInventory ) { - return true; + if ( this.configuredItem != null ) + { + IAEItemStack result = itemInventory.getStorageList().findPrecise( this.configuredItem ); + if ( result == null ) + this.configuredItem.setStackSize( 0 ); + else + this.configuredItem.setStackSize( result.getStackSize() ); + } } - @SideOnly(Side.CLIENT) - private boolean updateList; - - @SideOnly(Side.CLIENT) - private Integer dspList; - @Override - @SideOnly(Side.CLIENT) + @SideOnly( Side.CLIENT ) protected void finalize() throws Throwable { super.finalize(); @@ -193,8 +221,8 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit } @Override - @SideOnly(Side.CLIENT) - public void renderDynamic(double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer) + @SideOnly( Side.CLIENT ) + public void renderDynamic( double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer ) { if ( this.dspList == null ) this.dspList = GLAllocation.generateDisplayLists( 1 ); @@ -203,7 +231,7 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit if ( Platform.isDrawing( tess ) ) return; - if ( (this.clientFlags & (this.POWERED_FLAG | this.CHANNEL_FLAG)) != (this.POWERED_FLAG | this.CHANNEL_FLAG) ) + if ( ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) != ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) return; IAEItemStack ais = (IAEItemStack) this.getDisplayed(); @@ -226,7 +254,19 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit } } - private void tesrRenderScreen(Tessellator tess, IAEItemStack ais) + @Override + public boolean requireDynamicRender() + { + return true; + } + + @Override + public IAEStack getDisplayed() + { + return this.configuredItem; + } + + private void tesrRenderScreen( Tessellator tess, IAEItemStack ais ) { GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS ); ForgeDirection d = this.side; @@ -288,9 +328,8 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit tess.setColorOpaque_F( 1.0f, 1.0f, 1.0f ); ClientHelper.proxy.doRenderItem( sis, this.tile.getWorldObj() ); - } - catch (Exception e) + catch ( Exception e ) { AELog.error( e ); } @@ -320,63 +359,21 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit GL11.glPopAttrib(); } - @Override - public IAEStack getDisplayed() - { - return this.configuredItem; - } - @Override public boolean isLocked() { return this.isLocked; } - IStackWatcher myWatcher; - @Override - public void updateWatcher(IStackWatcher newWatcher) + public void updateWatcher( IStackWatcher newWatcher ) { this.myWatcher = newWatcher; this.configureWatchers(); } - // update the system... - public void configureWatchers() - { - if ( this.myWatcher != null ) - this.myWatcher.clear(); - - try - { - if ( this.configuredItem != null ) - { - if ( this.myWatcher != null ) - this.myWatcher.add( this.configuredItem ); - - this.updateReportingValue( this.proxy.getStorage().getItemInventory() ); - } - } - catch (GridAccessException e) - { - // >.> - } - } - - private void updateReportingValue(IMEMonitor itemInventory) - { - if ( this.configuredItem != null ) - { - IAEItemStack result = itemInventory.getStorageList().findPrecise( this.configuredItem ); - if ( result == null ) - this.configuredItem.setStackSize( 0 ); - else - this.configuredItem.setStackSize( result.getStackSize() ); - } - } - @Override - public void onStackChange(IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan) + public void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan ) { if ( this.configuredItem != null ) { @@ -390,9 +387,8 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit } @Override - public boolean showNetworkInfo(MovingObjectPosition where) + public boolean showNetworkInfo( MovingObjectPosition where ) { return false; } - } diff --git a/src/main/java/appeng/parts/reporting/PartTerminal.java b/src/main/java/appeng/parts/reporting/PartTerminal.java index 0a4fade36..332668952 100644 --- a/src/main/java/appeng/parts/reporting/PartTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartTerminal.java @@ -18,6 +18,7 @@ package appeng.parts.reporting; + import java.util.List; import net.minecraft.entity.player.EntityPlayer; @@ -44,48 +45,17 @@ import appeng.util.ConfigManager; import appeng.util.IConfigManagerHost; import appeng.util.Platform; + public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigManagerHost, IViewCellStorage, IAEAppEngInventory { final IConfigManager cm = new ConfigManager( this ); final AppEngInternalInventory viewCell = new AppEngInternalInventory( this, 5 ); - public PartTerminal(Class clz, ItemStack is) { - super( clz, is, true ); - - this.cm.registerSetting( Settings.SORT_BY, SortOrder.NAME ); - this.cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL ); - this.cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING ); - } - - @Override - public void getDrops(List drops, boolean wrenched) + public PartTerminal( ItemStack is ) { - super.getDrops( drops, wrenched ); + super( is, true ); - for (ItemStack is : this.viewCell) - if ( is != null ) - drops.add( is ); - } - - @Override - public void readFromNBT(NBTTagCompound data) - { - super.readFromNBT( data ); - this.cm.readFromNBT( data ); - this.viewCell.readFromNBT( data, "viewCell" ); - } - - @Override - public void writeToNBT(NBTTagCompound data) - { - super.writeToNBT( data ); - this.cm.writeToNBT( data ); - this.viewCell.writeToNBT( data, "viewCell" ); - } - - public PartTerminal(ItemStack is) { - super( PartTerminal.class, is, true ); this.frontBright = CableBusTextures.PartTerminal_Bright; this.frontColored = CableBusTextures.PartTerminal_Colored; this.frontDark = CableBusTextures.PartTerminal_Dark; @@ -96,13 +66,40 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM this.cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING ); } - public GuiBridge getGui( EntityPlayer player ) + @Override + public void getDrops( List drops, boolean wrenched ) { - return GuiBridge.GUI_ME; + super.getDrops( drops, wrenched ); + + for ( ItemStack is : this.viewCell ) + if ( is != null ) + drops.add( is ); } @Override - public boolean onPartActivate(EntityPlayer player, Vec3 pos) + public IConfigManager getConfigManager() + { + return this.cm; + } + + @Override + public void writeToNBT( NBTTagCompound data ) + { + super.writeToNBT( data ); + this.cm.writeToNBT( data ); + this.viewCell.writeToNBT( data, "viewCell" ); + } + + @Override + public void readFromNBT( NBTTagCompound data ) + { + super.readFromNBT( data ); + this.cm.readFromNBT( data ); + this.viewCell.readFromNBT( data, "viewCell" ); + } + + @Override + public boolean onPartActivate( EntityPlayer player, Vec3 pos ) { if ( !super.onPartActivate( player, pos ) ) { @@ -119,18 +116,9 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM return false; } - @Override - public IMEMonitor getFluidInventory() + public GuiBridge getGui( EntityPlayer player ) { - try - { - return this.proxy.getStorage().getFluidInventory(); - } - catch (GridAccessException e) - { - // err nope? - } - return null; + return GuiBridge.GUI_ME; } @Override @@ -140,7 +128,7 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM { return this.proxy.getStorage().getItemInventory(); } - catch (GridAccessException e) + catch ( GridAccessException e ) { // err nope? } @@ -148,13 +136,21 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM } @Override - public IConfigManager getConfigManager() + public IMEMonitor getFluidInventory() { - return this.cm; + try + { + return this.proxy.getStorage().getFluidInventory(); + } + catch ( GridAccessException e ) + { + // err nope? + } + return null; } @Override - public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue) + public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue ) { } @@ -166,7 +162,7 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM } @Override - public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) + public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack ) { this.host.markForSave(); } diff --git a/src/main/java/appeng/recipes/AEItemResolver.java b/src/main/java/appeng/recipes/AEItemResolver.java index 4045792d2..d849e8a54 100644 --- a/src/main/java/appeng/recipes/AEItemResolver.java +++ b/src/main/java/appeng/recipes/AEItemResolver.java @@ -22,6 +22,9 @@ package appeng.recipes; import net.minecraft.item.ItemStack; import appeng.api.AEApi; +import appeng.api.definitions.IDefinitions; +import appeng.api.definitions.IItems; +import appeng.api.definitions.IParts; import appeng.api.recipes.ISubItemResolver; import appeng.api.recipes.ResolverResult; import appeng.api.recipes.ResolverResultSet; @@ -34,63 +37,68 @@ import appeng.items.misc.ItemCrystalSeed; import appeng.items.parts.ItemMultiPart; import appeng.items.parts.PartType; + public class AEItemResolver implements ISubItemResolver { @Override - public Object resolveItemByName(String nameSpace, String itemName) + public Object resolveItemByName( String nameSpace, String itemName ) { if ( nameSpace.equals( AppEng.MOD_ID ) ) { + final IDefinitions definitions = AEApi.instance().definitions(); + final IItems items = definitions.items(); + final IParts parts = definitions.parts(); + if ( itemName.startsWith( "PaintBall." ) ) { - return this.paintBall( AEApi.instance().items().itemPaintBall, itemName.substring( itemName.indexOf( "." ) + 1 ), false ); + return this.paintBall( items.coloredPaintBall(), itemName.substring( itemName.indexOf( '.' ) + 1 ), false ); } if ( itemName.startsWith( "LumenPaintBall." ) ) { - return this.paintBall( AEApi.instance().items().itemPaintBall, itemName.substring( itemName.indexOf( "." ) + 1 ), true ); + return this.paintBall( items.coloredLumenPaintBall(), itemName.substring( itemName.indexOf( '.' ) + 1 ), true ); } if ( itemName.equals( "CableGlass" ) ) { - return new ResolverResultSet( "CableGlass", AEApi.instance().parts().partCableGlass.allStacks( 1 ) ); + return new ResolverResultSet( "CableGlass", parts.cableGlass().allStacks( 1 ) ); } if ( itemName.startsWith( "CableGlass." ) ) { - return this.cableItem( AEApi.instance().parts().partCableGlass, itemName.substring( itemName.indexOf( "." ) + 1 ) ); + return this.cableItem( parts.cableGlass(), itemName.substring( itemName.indexOf( '.' ) + 1 ) ); } if ( itemName.equals( "CableCovered" ) ) { - return new ResolverResultSet( "CableCovered", AEApi.instance().parts().partCableCovered.allStacks( 1 ) ); + return new ResolverResultSet( "CableCovered", parts.cableCovered().allStacks( 1 ) ); } if ( itemName.startsWith( "CableCovered." ) ) { - return this.cableItem( AEApi.instance().parts().partCableCovered, itemName.substring( itemName.indexOf( "." ) + 1 ) ); + return this.cableItem( parts.cableCovered(), itemName.substring( itemName.indexOf( '.' ) + 1 ) ); } if ( itemName.equals( "CableSmart" ) ) { - return new ResolverResultSet( "CableSmart", AEApi.instance().parts().partCableSmart.allStacks( 1 ) ); + return new ResolverResultSet( "CableSmart", parts.cableSmart().allStacks( 1 ) ); } if ( itemName.startsWith( "CableSmart." ) ) { - return this.cableItem( AEApi.instance().parts().partCableSmart, itemName.substring( itemName.indexOf( "." ) + 1 ) ); + return this.cableItem( parts.cableSmart(), itemName.substring( itemName.indexOf( '.' ) + 1 ) ); } if ( itemName.equals( "CableDense" ) ) { - return new ResolverResultSet( "CableDense", AEApi.instance().parts().partCableDense.allStacks( 1 ) ); + return new ResolverResultSet( "CableDense", parts.cableDense().allStacks( 1 ) ); } if ( itemName.startsWith( "CableDense." ) ) { - return this.cableItem( AEApi.instance().parts().partCableDense, itemName.substring( itemName.indexOf( "." ) + 1 ) ); + return this.cableItem( parts.cableDense(), itemName.substring( itemName.indexOf( '.' ) + 1 ) ); } if ( itemName.startsWith( "ItemCrystalSeed." ) ) @@ -107,7 +115,7 @@ public class AEItemResolver implements ISubItemResolver if ( itemName.startsWith( "ItemMaterial." ) ) { - String materialName = itemName.substring( itemName.indexOf( "." ) + 1 ); + String materialName = itemName.substring( itemName.indexOf( '.' ) + 1 ); MaterialType mt = MaterialType.valueOf( materialName ); // itemName = itemName.substring( 0, itemName.indexOf( "." ) ); if ( mt.itemInstance == ItemMultiMaterial.instance && mt.damageValue >= 0 && mt.isRegistered() ) @@ -116,7 +124,7 @@ public class AEItemResolver implements ISubItemResolver if ( itemName.startsWith( "ItemPart." ) ) { - String partName = itemName.substring( itemName.indexOf( "." ) + 1 ); + String partName = itemName.substring( itemName.indexOf( '.' ) + 1 ); PartType pt = PartType.valueOf( partName ); // itemName = itemName.substring( 0, itemName.indexOf( "." ) ); int dVal = ItemMultiPart.instance.getDamageByType( pt ); @@ -128,15 +136,15 @@ public class AEItemResolver implements ISubItemResolver return null; } - private Object paintBall(AEColoredItemDefinition partType, String substring, boolean lumen) + private Object paintBall( AEColoredItemDefinition partType, String substring, boolean lumen ) { - AEColor col = AEColor.Transparent; + AEColor col; try { col = AEColor.valueOf( substring ); } - catch (Throwable t) + catch ( Throwable t ) { col = AEColor.Transparent; } @@ -145,18 +153,18 @@ public class AEItemResolver implements ISubItemResolver return null; ItemStack is = partType.stack( col, 1 ); - return new ResolverResult( "ItemPaintBall", (lumen ? 20 : 0) + is.getItemDamage() ); + return new ResolverResult( "ItemPaintBall", ( lumen ? 20 : 0 ) + is.getItemDamage() ); } - private Object cableItem(AEColoredItemDefinition partType, String substring) + private Object cableItem( AEColoredItemDefinition partType, String substring ) { - AEColor col = AEColor.Transparent; + AEColor col; try { col = AEColor.valueOf( substring ); } - catch (Throwable t) + catch ( Throwable t ) { col = AEColor.Transparent; } diff --git a/src/main/java/appeng/recipes/RecipeHandler.java b/src/main/java/appeng/recipes/RecipeHandler.java index 2ebc55534..90e5b2cd9 100644 --- a/src/main/java/appeng/recipes/RecipeHandler.java +++ b/src/main/java/appeng/recipes/RecipeHandler.java @@ -30,15 +30,20 @@ import java.util.Map.Entry; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import cpw.mods.fml.common.LoaderState; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; +import com.google.common.base.Optional; import com.google.common.collect.HashMultimap; import appeng.api.AEApi; +import appeng.api.definitions.IBlocks; +import appeng.api.definitions.IDefinitions; +import appeng.api.definitions.IItems; import appeng.api.exceptions.MissingIngredientError; import appeng.api.exceptions.RecipeError; import appeng.api.exceptions.RegistrationError; @@ -258,7 +263,17 @@ public class RecipeHandler implements IRecipeHandler if ( !id.modId.equals( AppEng.MOD_ID ) && !id.modId.equals( "minecraft" ) ) throw new RecipeError( "Not applicable for website" ); - if ( is.getItem() == AEApi.instance().items().itemCrystalSeed.item() ) + final IDefinitions definitions = AEApi.instance().definitions(); + final IItems items = definitions.items(); + final IBlocks blocks = definitions.blocks(); + + final Optional maybeCrystalSeedItem = items.crystalSeed().maybeItem(); + final Optional maybeSkyStoneItem = blocks.skyStone().maybeItem(); + final Optional maybeCraftingStorageItem = blocks.craftingStorage1k().maybeItem(); + final Optional maybeCraftingUnitItem = blocks.craftingUnit().maybeItem(); + final Optional maybeSkyChestItem = blocks.skyChest().maybeItem(); + + if ( maybeCrystalSeedItem.isPresent() && is.getItem() == maybeCrystalSeedItem.get() ) { int dmg = is.getItemDamage(); if ( dmg < ItemCrystalSeed.Nether ) @@ -268,7 +283,7 @@ public class RecipeHandler implements IRecipeHandler else if ( dmg < ItemCrystalSeed.END ) realName += ".Fluix"; } - else if ( is.getItem() == AEApi.instance().blocks().blockSkyStone.item() ) + else if ( maybeSkyStoneItem.isPresent() && is.getItem() == maybeSkyStoneItem.get() ) { switch (is.getItemDamage()) { @@ -284,7 +299,7 @@ public class RecipeHandler implements IRecipeHandler default: } } - else if ( is.getItem() == AEApi.instance().blocks().blockCraftingStorage1k.item() ) + else if ( maybeCraftingStorageItem.isPresent() && is.getItem() == maybeCraftingStorageItem.get() ) { switch (is.getItemDamage()) { @@ -300,7 +315,7 @@ public class RecipeHandler implements IRecipeHandler default: } } - else if ( is.getItem() == AEApi.instance().blocks().blockCraftingUnit.item() ) + else if ( maybeCraftingUnitItem.isPresent() && is.getItem() == maybeCraftingUnitItem.get() ) { switch (is.getItemDamage()) { @@ -310,7 +325,7 @@ public class RecipeHandler implements IRecipeHandler default: } } - else if ( is.getItem() == AEApi.instance().blocks().blockSkyChest.item() ) + else if ( maybeSkyChestItem.isPresent() && is.getItem() == maybeSkyChestItem.get() ) { switch (is.getItemDamage()) { diff --git a/src/main/java/appeng/recipes/game/DisassembleRecipe.java b/src/main/java/appeng/recipes/game/DisassembleRecipe.java index 97a01b07c..7a524d511 100644 --- a/src/main/java/appeng/recipes/game/DisassembleRecipe.java +++ b/src/main/java/appeng/recipes/game/DisassembleRecipe.java @@ -18,32 +18,69 @@ package appeng.recipes.game; + +import java.util.HashMap; +import java.util.Map; + import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.world.World; import appeng.api.AEApi; -import appeng.api.definitions.Blocks; -import appeng.api.definitions.Items; -import appeng.api.definitions.Materials; +import appeng.api.definitions.IBlocks; +import appeng.api.definitions.IDefinitions; +import appeng.api.definitions.IItemDefinition; +import appeng.api.definitions.IItems; +import appeng.api.definitions.IMaterials; import appeng.api.storage.IMEInventory; import appeng.api.storage.StorageChannel; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; + public class DisassembleRecipe implements IRecipe { - private final Materials mats = AEApi.instance().materials(); - private final Items items = AEApi.instance().items(); - private final Blocks blocks = AEApi.instance().blocks(); + private final IMaterials mats; + private final IItems items; + private final IBlocks blocks; + private final Map cellMappings; + private final Map nonCellMappings; - private ItemStack getOutput(InventoryCrafting inv, boolean createFacade) + public DisassembleRecipe() + { + final IDefinitions definitions = AEApi.instance().definitions(); + + this.blocks = definitions.blocks(); + this.items = definitions.items(); + this.mats = definitions.materials(); + this.cellMappings = new HashMap( 4 ); + this.nonCellMappings = new HashMap( 5 ); + + this.cellMappings.put( this.items.cell1k(), this.mats.cell1kPart() ); + this.cellMappings.put( this.items.cell4k(), this.mats.cell4kPart() ); + this.cellMappings.put( this.items.cell16k(), this.mats.cell16kPart() ); + this.cellMappings.put( this.items.cell64k(), this.mats.cell64kPart() ); + + this.nonCellMappings.put( this.items.encodedPattern(), this.mats.blankPattern() ); + this.nonCellMappings.put( this.blocks.craftingStorage1k(), this.mats.cell1kPart() ); + this.nonCellMappings.put( this.blocks.craftingStorage4k(), this.mats.cell4kPart() ); + this.nonCellMappings.put( this.blocks.craftingStorage16k(), this.mats.cell16kPart() ); + this.nonCellMappings.put( this.blocks.craftingStorage64k(), this.mats.cell64kPart() ); + } + + @Override + public boolean matches( InventoryCrafting inv, World w ) + { + return this.getOutput( inv, false ) != null; + } + + private ItemStack getOutput( InventoryCrafting inv, boolean createFacade ) { ItemStack hasCell = null; - for (int x = 0; x < inv.getSizeInventory(); x++) + for ( int x = 0; x < inv.getSizeInventory(); x++ ) { ItemStack is = inv.getStackInSlot( x ); if ( is != null ) @@ -51,17 +88,7 @@ public class DisassembleRecipe implements IRecipe if ( hasCell != null ) return null; - if ( this.items.itemCell1k.sameAsStack( is ) ) - hasCell = this.mats.materialCell1kPart.stack( 1 ); - - if ( this.items.itemCell4k.sameAsStack( is ) ) - hasCell = this.mats.materialCell4kPart.stack( 1 ); - - if ( this.items.itemCell16k.sameAsStack( is ) ) - hasCell = this.mats.materialCell16kPart.stack( 1 ); - - if ( this.items.itemCell64k.sameAsStack( is ) ) - hasCell = this.mats.materialCell64kPart.stack( 1 ); + hasCell = this.getCellOutput( is ); // make sure the storage cell is empty... if ( hasCell != null ) @@ -75,20 +102,7 @@ public class DisassembleRecipe implements IRecipe } } - if ( this.items.itemEncodedPattern.sameAsStack( is ) ) - hasCell = this.mats.materialBlankPattern.stack( 1 ); - - if ( this.blocks.blockCraftingStorage1k.sameAsStack( is ) ) - hasCell = this.mats.materialCell1kPart.stack( 1 ); - - if ( this.blocks.blockCraftingStorage4k.sameAsStack( is ) ) - hasCell = this.mats.materialCell4kPart.stack( 1 ); - - if ( this.blocks.blockCraftingStorage16k.sameAsStack( is ) ) - hasCell = this.mats.materialCell16kPart.stack( 1 ); - - if ( this.blocks.blockCraftingStorage64k.sameAsStack( is ) ) - hasCell = this.mats.materialCell64kPart.stack( 1 ); + hasCell = this.getNonCellOutput( is ); if ( hasCell == null ) return null; @@ -98,14 +112,34 @@ public class DisassembleRecipe implements IRecipe return hasCell; } - @Override - public boolean matches(InventoryCrafting inv, World w) + private ItemStack getCellOutput( ItemStack compared ) { - return this.getOutput( inv, false ) != null; + for ( Map.Entry entry : this.cellMappings.entrySet() ) + { + if ( entry.getKey().isSameAs( compared ) ) + { + return entry.getValue().maybeStack( 1 ).get(); + } + } + + return null; + } + + private ItemStack getNonCellOutput( ItemStack compared ) + { + for ( Map.Entry entry : this.nonCellMappings.entrySet() ) + { + if ( entry.getKey().isSameAs( compared ) ) + { + return entry.getValue().maybeStack( 1 ).get(); + } + } + + return null; } @Override - public ItemStack getCraftingResult(InventoryCrafting inv) + public ItemStack getCraftingResult( InventoryCrafting inv ) { return this.getOutput( inv, true ); } @@ -121,5 +155,4 @@ public class DisassembleRecipe implements IRecipe { return null; } - } \ No newline at end of file diff --git a/src/main/java/appeng/recipes/game/FacadeRecipe.java b/src/main/java/appeng/recipes/game/FacadeRecipe.java index b25419216..4ef65a260 100644 --- a/src/main/java/appeng/recipes/game/FacadeRecipe.java +++ b/src/main/java/appeng/recipes/game/FacadeRecipe.java @@ -19,6 +19,8 @@ package appeng.recipes.game; +import javax.annotation.Nullable; + import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; @@ -29,20 +31,23 @@ import net.minecraft.world.World; import com.google.common.base.Optional; import appeng.api.AEApi; -import appeng.api.util.AEItemDefinition; +import appeng.api.definitions.IComparableDefinition; +import appeng.api.definitions.IDefinitions; import appeng.items.parts.ItemFacade; -public class FacadeRecipe implements IRecipe +public final class FacadeRecipe implements IRecipe { - private final Optional maybeAnchor; - private final Optional maybeFacade; + private final IComparableDefinition anchor; + private final Optional maybeFacade; public FacadeRecipe() { - this.maybeFacade = Optional.fromNullable( AEApi.instance().items().itemFacade ); - this.maybeAnchor = Optional.fromNullable( AEApi.instance().parts().partCableAnchor ); + final IDefinitions definitions = AEApi.instance().definitions(); + + this.maybeFacade = definitions.items().facade().maybeItem(); + this.anchor = definitions.parts().cableAnchor(); } @Override @@ -51,24 +56,25 @@ public class FacadeRecipe implements IRecipe return this.getOutput( inv, false ) != null; } + @Nullable private ItemStack getOutput( IInventory inv, boolean createFacade ) { - if ( this.maybeAnchor.isPresent() && this.maybeFacade.isPresent() && inv.getStackInSlot( 0 ) == null && inv.getStackInSlot( 2 ) == null && inv.getStackInSlot( 6 ) == null && inv.getStackInSlot( 8 ) == null ) + if ( inv.getStackInSlot( 0 ) == null && inv.getStackInSlot( 2 ) == null && inv.getStackInSlot( 6 ) == null && inv.getStackInSlot( 8 ) == null ) { - final AEItemDefinition anchorDefinition = this.maybeAnchor.get(); - final AEItemDefinition facadeDefinition = this.maybeFacade.get(); - - if ( anchorDefinition.sameAsStack( inv.getStackInSlot( 1 ) ) && anchorDefinition.sameAsStack( inv.getStackInSlot( 3 ) ) && anchorDefinition.sameAsStack( inv.getStackInSlot( 5 ) ) && anchorDefinition.sameAsStack( inv.getStackInSlot( 7 ) ) ) + if ( this.anchor.isSameAs( inv.getStackInSlot( 1 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 3 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 5 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 7 ) ) ) { - final Item itemDefinition = facadeDefinition.item(); - final ItemFacade facade = (ItemFacade) itemDefinition; + for ( Item facadeItemDefinition : this.maybeFacade.asSet() ) + { + final ItemFacade facade = (ItemFacade) facadeItemDefinition; - ItemStack facades = facade.createFacadeForItem( inv.getStackInSlot( 4 ), !createFacade ); - if ( facades != null && createFacade ) - facades.stackSize = 4; - return facades; + ItemStack facades = facade.createFacadeForItem( inv.getStackInSlot( 4 ), !createFacade ); + if ( facades != null && createFacade ) + facades.stackSize = 4; + return facades; + } } } + return null; } diff --git a/src/main/java/appeng/server/AECommand.java b/src/main/java/appeng/server/AECommand.java index 5264cbe8a..f08e31751 100644 --- a/src/main/java/appeng/server/AECommand.java +++ b/src/main/java/appeng/server/AECommand.java @@ -69,10 +69,12 @@ public class AECommand extends CommandBase throw new WrongUsageException( c.command.getHelp( this.srv ) ); } } + catch ( WrongUsageException wrong ) + { + throw wrong; + } catch (Throwable er) { - if ( er instanceof WrongUsageException ) - throw (WrongUsageException) er; throw new WrongUsageException( "commands.ae2.usage" ); } } @@ -90,10 +92,12 @@ public class AECommand extends CommandBase else throw new WrongUsageException( "commands.ae2.permissions" ); } + catch ( WrongUsageException wrong ) + { + throw wrong; + } catch (Throwable er) { - if ( er instanceof WrongUsageException ) - throw (WrongUsageException) er; throw new WrongUsageException( "commands.ae2.usage" ); } } diff --git a/src/main/java/appeng/services/CompassService.java b/src/main/java/appeng/services/CompassService.java index 03bc499fa..b6a56665f 100644 --- a/src/main/java/appeng/services/CompassService.java +++ b/src/main/java/appeng/services/CompassService.java @@ -18,8 +18,10 @@ package appeng.services; + import java.io.File; import java.util.HashMap; +import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; @@ -35,10 +37,147 @@ import appeng.api.util.DimensionalCoord; import appeng.services.compass.CompassReader; import appeng.services.compass.ICompassCallback; + public class CompassService implements ThreadFactory { + private static final int CHUNK_SIZE = 16; + private final Map worldSet = new HashMap(); + private final ExecutorService executor; + private final File rootFolder; + private int jobSize = 0; + + public CompassService( File aEFolder ) + { + this.rootFolder = aEFolder; + this.executor = Executors.newSingleThreadExecutor( this ); + this.jobSize = 0; + } + + public Future getCompassDirection( DimensionalCoord coord, int maxRange, ICompassCallback cc ) + { + this.jobSize++; + return this.executor.submit( new CMDirectionRequest( coord, maxRange, cc ) ); + } + + public int jobSize() + { + return this.jobSize; + } + + public void cleanUp() + { + for ( CompassReader cr : this.worldSet.values() ) + cr.close(); + } + + public void updateArea( World w, int chunkX, int chunkZ ) + { + int x = chunkX << 4; + int z = chunkZ << 4; + + this.updateArea( w, x, CHUNK_SIZE, z ); + this.updateArea( w, x, CHUNK_SIZE + 32, z ); + this.updateArea( w, x, CHUNK_SIZE + 64, z ); + this.updateArea( w, x, CHUNK_SIZE + 96, z ); + + this.updateArea( w, x, CHUNK_SIZE + 128, z ); + this.updateArea( w, x, CHUNK_SIZE + 160, z ); + this.updateArea( w, x, CHUNK_SIZE + 192, z ); + this.updateArea( w, x, CHUNK_SIZE + 224, z ); + } + + public Future updateArea( World w, int x, int y, int z ) + { + this.jobSize++; + + int cx = x >> 4; + int cdy = y >> 5; + int cz = z >> 4; + + int low_y = cdy << 5; + int hi_y = low_y + 32; + + // lower level... + Chunk c = w.getChunkFromBlockCoords( x, z ); + + for ( Block skyStoneBlock : AEApi.instance().definitions().blocks().skyStone().maybeBlock().asSet() ) + { + for ( int i = 0; i < CHUNK_SIZE; i++ ) + { + for ( int j = 0; j < CHUNK_SIZE; j++ ) + { + for ( int k = low_y; k < hi_y; k++ ) + { + Block blk = c.getBlock( i, k, j ); + if ( blk == skyStoneBlock && c.getBlockMetadata( i, k, j ) == 0 ) + { + return this.executor.submit( new CMUpdatePost( w, cx, cz, cdy, true ) ); + } + } + } + } + } + + return this.executor.submit( new CMUpdatePost( w, cx, cz, cdy, false ) ); + } + + private CompassReader getReader( World w ) + { + CompassReader cr = this.worldSet.get( w ); + + if ( cr == null ) + { + cr = new CompassReader( w.provider.dimensionId, this.rootFolder ); + this.worldSet.put( w, cr ); + } + + return cr; + } + + private int dist( int ax, int az, int bx, int bz ) + { + int up = ( bz - az ) * CHUNK_SIZE; + int side = ( bx - ax ) * CHUNK_SIZE; + + return up * up + side * side; + } + + private double rad( int ax, int az, int bx, int bz ) + { + int up = bz - az; + int side = bx - ax; + + return Math.atan2( -up, side ) - Math.PI / 2.0; + } + + public void kill() + { + this.executor.shutdown(); + + try + { + this.executor.awaitTermination( 6, TimeUnit.MINUTES ); + this.jobSize = 0; + + for ( CompassReader cr : this.worldSet.values() ) + { + cr.close(); + } + + this.worldSet.clear(); + } + catch ( InterruptedException e ) + { + // wrap this up.. + } + } + + @Override + public Thread newThread( Runnable job ) + { + return new Thread( job, "AE Compass Service" ); + } - int jobSize = 0; private class CMUpdatePost implements Runnable { @@ -50,7 +189,8 @@ public class CompassService implements ThreadFactory public final int doubleChunkY; // 32 blocks instead of 16. public final boolean value; - public CMUpdatePost(World w, int cx, int cz, int dcy, boolean val) { + public CMUpdatePost( World w, int cx, int cz, int dcy, boolean val ) + { this.world = w; this.chunkX = cx; this.doubleChunkY = dcy; @@ -69,9 +209,9 @@ public class CompassService implements ThreadFactory if ( CompassService.this.jobSize() < 2 ) CompassService.this.cleanUp(); } - } + private class CMDirectionRequest implements Runnable { @@ -79,7 +219,8 @@ public class CompassService implements ThreadFactory public final DimensionalCoord coord; public final ICompassCallback callback; - public CMDirectionRequest(DimensionalCoord coord, int getMaxRange, ICompassCallback cc) { + public CMDirectionRequest( DimensionalCoord coord, int getMaxRange, ICompassCallback cc ) + { this.coord = coord; this.maxRange = getMaxRange; this.callback = cc; @@ -107,7 +248,7 @@ public class CompassService implements ThreadFactory } // spiral outward... - for (int offset = 1; offset < this.maxRange; offset++) + for ( int offset = 1; offset < this.maxRange; offset++ ) { int minX = cx - offset; int minZ = cz - offset; @@ -118,7 +259,7 @@ public class CompassService implements ThreadFactory int chosen_x = cx; int chosen_z = cz; - for (int z = minZ; z <= maxZ; z++) + for ( int z = minZ; z <= maxZ; z++ ) { if ( cr.hasBeacon( minX, z ) ) { @@ -143,7 +284,7 @@ public class CompassService implements ThreadFactory } } - for (int x = minX + 1; x < maxX; x++) + for ( int x = minX + 1; x < maxX; x++ ) { if ( cr.hasBeacon( x, minZ ) ) { @@ -186,139 +327,4 @@ public class CompassService implements ThreadFactory CompassService.this.cleanUp(); } } - - public Future getCompassDirection(DimensionalCoord coord, int maxRange, ICompassCallback cc) - { - this.jobSize++; - return this.executor.submit( new CMDirectionRequest( coord, maxRange, cc ) ); - } - - public int jobSize() - { - return this.jobSize; - } - - public void cleanUp() - { - for (CompassReader cr : this.worldSet.values()) - cr.close(); - } - - public void updateArea(World w, int chunkX, int chunkZ) - { - int x = chunkX << 4; - int z = chunkZ << 4; - - this.updateArea( w, x, 16, z ); - this.updateArea( w, x, 16 + 32, z ); - this.updateArea( w, x, 16 + 64, z ); - this.updateArea( w, x, 16 + 96, z ); - - this.updateArea( w, x, 16 + 128, z ); - this.updateArea( w, x, 16 + 160, z ); - this.updateArea( w, x, 16 + 192, z ); - this.updateArea( w, x, 16 + 224, z ); - } - - public Future updateArea(World w, int x, int y, int z) - { - this.jobSize++; - - int cx = x >> 4; - int cdy = y >> 5; - int cz = z >> 4; - - int low_y = cdy << 5; - int hi_y = low_y + 32; - - Block skystone = AEApi.instance().blocks().blockSkyStone.block(); - - // lower level... - Chunk c = w.getChunkFromBlockCoords( x, z ); - - for (int i = 0; i < 16; i++) - { - for (int j = 0; j < 16; j++) - { - for (int k = low_y; k < hi_y; k++) - { - Block blk = c.getBlock( i, k, j ); - if ( blk == skystone && c.getBlockMetadata( i, k, j ) == 0 ) - { - return this.executor.submit( new CMUpdatePost( w, cx, cz, cdy, true ) ); - } - } - } - } - - return this.executor.submit( new CMUpdatePost( w, cx, cz, cdy, false ) ); - } - - final HashMap worldSet = new HashMap(); - final ExecutorService executor; - - final File rootFolder; - - public CompassService(File aEFolder) { - this.rootFolder = aEFolder; - this.executor = Executors.newSingleThreadExecutor( this ); - this.jobSize = 0; - } - - private CompassReader getReader(World w) - { - CompassReader cr = this.worldSet.get( w ); - - if ( cr == null ) - { - cr = new CompassReader( w.provider.dimensionId, this.rootFolder ); - this.worldSet.put( w, cr ); - } - - return cr; - } - - private int dist(int ax, int az, int bx, int bz) - { - int up = (bz - az) * 16; - int side = (bx - ax) * 16; - - return up * up + side * side; - } - - private double rad(int ax, int az, int bx, int bz) - { - int up = bz - az; - int side = bx - ax; - - return Math.atan2( -up, side ) - Math.PI / 2.0; - } - - public void kill() - { - this.executor.shutdown(); - - try - { - this.executor.awaitTermination( 6, TimeUnit.MINUTES ); - this.jobSize = 0; - - for (CompassReader cr : this.worldSet.values()) - { - cr.close(); - } - - this.worldSet.clear(); - } - catch (InterruptedException e) - { - // wrap this up.. - } - } - - @Override - public Thread newThread(Runnable job) - { - return new Thread( job, "AE Compass Service" ); - } } diff --git a/src/main/java/appeng/spatial/CachedPlane.java b/src/main/java/appeng/spatial/CachedPlane.java index 108eeb3ad..77779277d 100644 --- a/src/main/java/appeng/spatial/CachedPlane.java +++ b/src/main/java/appeng/spatial/CachedPlane.java @@ -18,6 +18,7 @@ package appeng.spatial; + import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -33,6 +34,7 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import net.minecraftforge.common.util.ForgeDirection; import appeng.api.AEApi; +import appeng.api.definitions.IBlockDefinition; import appeng.api.movable.IMovableHandler; import appeng.api.movable.IMovableRegistry; import appeng.api.util.WorldCoord; @@ -40,102 +42,29 @@ import appeng.core.AELog; import appeng.core.WorldSettings; import appeng.util.Platform; + public class CachedPlane { - - class Column - { - - private final int x; - private final int z; - private final Chunk c; - private final Object[] ch = { 0, 0, 0 }; - private List skipThese = null; - - private final ExtendedBlockStorage[] storage; - - public Column(Chunk _c, int _x, int _z, int cy, int chunkHeight) { - this.x = _x; - this.z = _z; - this.c = _c; - this.storage = this.c.getBlockStorageArray(); - - // make sure storage exists before hand... - for (int ay = 0; ay < chunkHeight; ay++) - { - int by = (ay + cy); - ExtendedBlockStorage extendedblockstorage = this.storage[by]; - if ( extendedblockstorage == null ) - extendedblockstorage = this.storage[by] = new ExtendedBlockStorage( by << 4, !this.c.worldObj.provider.hasNoSky ); - } - } - - public void setBlockIDWithMetadata(int y, Object[] blk) - { - if ( blk[0] == CachedPlane.this.matrixFrame ) - blk[0] = Platform.AIR; - - ExtendedBlockStorage extendedBlockStorage = this.storage[y >> 4]; - extendedBlockStorage.func_150818_a( this.x, y & 15, this.z, (Block) blk[0] ); - // extendedBlockStorage.setExtBlockID( x, y & 15, z, blk[0] ); - extendedBlockStorage.setExtBlockMetadata( this.x, y & 15, this.z, (Integer) blk[1] ); - extendedBlockStorage.setExtBlocklightValue( this.x, y & 15, this.z, (Integer) blk[2] ); - } - - public Object[] getDetails(int y) - { - ExtendedBlockStorage extendedblockstorage = this.storage[y >> 4]; - this.ch[0] = extendedblockstorage.getBlockByExtId( this.x, y & 15, this.z ); - this.ch[1] = extendedblockstorage.getExtBlockMetadata( this.x, y & 15, this.z ); - this.ch[2] = extendedblockstorage.getExtBlocklightValue( this.x, y & 15, this.z ); - return this.ch; - } - - public boolean doNotSkip(int y) - { - ExtendedBlockStorage extendedblockstorage = this.storage[y >> 4]; - if ( CachedPlane.this.reg.isBlacklisted( extendedblockstorage.getBlockByExtId( this.x, y & 15, this.z ) ) ) - return false; - - return this.skipThese == null || !this.skipThese.contains( y ); - } - - public void setSkip(int yCoord) - { - if ( this.skipThese == null ) - this.skipThese = new LinkedList(); - this.skipThese.add( yCoord ); - } - - } - - int verticalBits; - final int x_size; final int z_size; - final int cx_size; final int cz_size; - final int x_offset; final int y_offset; final int z_offset; - final int y_size; - final Chunk[][] myChunks; final Column[][] myColumns; - final LinkedList tiles = new LinkedList(); final LinkedList ticks = new LinkedList(); - final World world; - final Block matrixFrame = AEApi.instance().blocks().blockMatrixFrame.block(); final IMovableRegistry reg = AEApi.instance().registries().movable(); - final LinkedList updates = new LinkedList(); + private final IBlockDefinition matrixFrame = AEApi.instance().definitions().blocks().matrixFrame(); + int verticalBits; - public CachedPlane(World w, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) { + public CachedPlane( World w, int minX, int minY, int minZ, int maxX, int maxY, int maxZ ) + { this.world = w; @@ -162,21 +91,21 @@ public class CachedPlane this.myColumns = new Column[this.x_size][this.z_size]; this.verticalBits = 0; - for (int cy = 0; cy < cy_size; cy++) + for ( int cy = 0; cy < cy_size; cy++ ) { - this.verticalBits |= 1 << (minCY + cy); + this.verticalBits |= 1 << ( minCY + cy ); } - for (int x = 0; x < this.x_size; x++) - for (int z = 0; z < this.z_size; z++) + for ( int x = 0; x < this.x_size; x++ ) + for ( int z = 0; z < this.z_size; z++ ) { - this.myColumns[x][z] = new Column( w.getChunkFromChunkCoords( (minX + x) >> 4, (minZ + z) >> 4 ), (minX + x) & 0xF, (minZ + z) & 0xF, minCY, cy_size ); + this.myColumns[x][z] = new Column( w.getChunkFromChunkCoords( ( minX + x ) >> 4, ( minZ + z ) >> 4 ), ( minX + x ) & 0xF, ( minZ + z ) & 0xF, minCY, cy_size ); } IMovableRegistry mr = AEApi.instance().registries().movable(); - for (int cx = 0; cx < this.cx_size; cx++) - for (int cz = 0; cz < this.cz_size; cz++) + for ( int cx = 0; cx < this.cx_size; cx++ ) + for ( int cz = 0; cz < this.cz_size; cz++ ) { LinkedList> rawTiles = new LinkedList>(); LinkedList deadTiles = new LinkedList(); @@ -184,8 +113,8 @@ public class CachedPlane Chunk c = w.getChunkFromChunkCoords( minCX + cx, minCZ + cz ); this.myChunks[cx][cz] = c; - rawTiles.addAll( ( ( HashMap ) c.chunkTileEntityMap ).entrySet() ); - for (Entry tx : rawTiles) + rawTiles.addAll( ( (HashMap) c.chunkTileEntityMap ).entrySet() ); + for ( Entry tx : rawTiles ) { ChunkPosition cp = tx.getKey(); TileEntity te = tx.getValue(); @@ -202,8 +131,7 @@ public class CachedPlane Block blk = (Block) details[0]; // don't skip air, just let the code replace it... - if ( blk != null && blk.isAir( c.worldObj, te.xCoord, te.yCoord, te.zCoord ) - && blk.isReplaceable( c.worldObj, te.xCoord, te.yCoord, te.zCoord ) ) + if ( blk != null && blk.isAir( c.worldObj, te.xCoord, te.yCoord, te.zCoord ) && blk.isReplaceable( c.worldObj, te.xCoord, te.yCoord, te.zCoord ) ) { c.worldObj.setBlock( te.xCoord, te.yCoord, te.zCoord, Platform.AIR ); c.worldObj.notifyBlocksOfNeighborChange( te.xCoord, te.yCoord, te.zCoord, Platform.AIR ); @@ -214,7 +142,7 @@ public class CachedPlane } } - for (ChunkPosition cp : deadTiles) + for ( ChunkPosition cp : deadTiles ) { c.chunkTileEntityMap.remove( cp ); } @@ -223,11 +151,10 @@ public class CachedPlane List list = this.world.getPendingBlockUpdates( c, false ); if ( list != null ) { - for (Object o : list) + for ( Object o : list ) { NextTickListEntry entry = (NextTickListEntry) o; - if ( entry.xCoord >= minX && entry.xCoord <= maxX && entry.yCoord >= minY && entry.yCoord <= maxY && entry.zCoord >= minZ - && entry.zCoord <= maxZ ) + if ( entry.xCoord >= minX && entry.xCoord <= maxX && entry.yCoord >= minY && entry.yCoord <= maxY && entry.zCoord >= minZ && entry.zCoord <= maxZ ) { NextTickListEntry newEntry = new NextTickListEntry( entry.xCoord, entry.yCoord, entry.zCoord, entry.func_151351_a() ); newEntry.scheduledTime = entry.scheduledTime - k; @@ -235,29 +162,28 @@ public class CachedPlane } } } - } - for (TileEntity te : this.tiles) + for ( TileEntity te : this.tiles ) { try { this.world.loadedTileEntityList.remove( te ); } - catch (Exception e) + catch ( Exception e ) { AELog.error( e ); } } } - private IMovableHandler getHandler(TileEntity te) + private IMovableHandler getHandler( TileEntity te ) { IMovableRegistry mr = AEApi.instance().registries().movable(); return mr.getHandler( te ); } - void Swap(CachedPlane dst) + void Swap( CachedPlane dst ) { IMovableRegistry mr = AEApi.instance().registries().movable(); @@ -267,14 +193,14 @@ public class CachedPlane long startTime = System.nanoTime(); - for (int x = 0; x < this.x_size; x++) + for ( int x = 0; x < this.x_size; x++ ) { - for (int z = 0; z < this.z_size; z++) + for ( int z = 0; z < this.z_size; z++ ) { Column a = this.myColumns[x][z]; Column b = dst.myColumns[x][z]; - for (int y = 0; y < this.y_size; y++) + for ( int y = 0; y < this.y_size; y++ ) { int src_y = y + this.y_offset; int dst_y = y + dst.y_offset; @@ -293,7 +219,6 @@ public class CachedPlane dst.markForUpdate( x + dst.x_offset, dst_y, z + dst.z_offset ); } } - } } @@ -301,22 +226,22 @@ public class CachedPlane long duration = endTime - startTime; AELog.info( "Block Copy Time: " + duration ); - for (TileEntity te : this.tiles) + for ( TileEntity te : this.tiles ) { dst.addTile( te.xCoord - this.x_offset, te.yCoord - this.y_offset, te.zCoord - this.z_offset, te, this, mr ); } - for (TileEntity te : dst.tiles) + for ( TileEntity te : dst.tiles ) { this.addTile( te.xCoord - dst.x_offset, te.yCoord - dst.y_offset, te.zCoord - dst.z_offset, te, dst, mr ); } - for (NextTickListEntry entry : this.ticks) + for ( NextTickListEntry entry : this.ticks ) { dst.addTick( entry.xCoord - this.x_offset, entry.yCoord - this.y_offset, entry.zCoord - this.z_offset, entry ); } - for (NextTickListEntry entry : dst.ticks) + for ( NextTickListEntry entry : dst.ticks ) { this.addTick( entry.xCoord - dst.x_offset, entry.yCoord - dst.y_offset, entry.zCoord - dst.z_offset, entry ); } @@ -331,19 +256,19 @@ public class CachedPlane } } - private void markForUpdate(int src_x, int src_y, int src_z) + private void markForUpdate( int src_x, int src_y, int src_z ) { this.updates.add( new WorldCoord( src_x, src_y, src_z ) ); - for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) + for ( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS ) this.updates.add( new WorldCoord( src_x + d.offsetX, src_y + d.offsetY, src_z + d.offsetZ ) ); } - private void addTick(int x, int y, int z, NextTickListEntry entry) + private void addTick( int x, int y, int z, NextTickListEntry entry ) { this.world.scheduleBlockUpdate( x + this.x_offset, y + this.y_offset, z + this.z_offset, entry.func_151351_a(), (int) entry.scheduledTime ); } - private void addTile(int x, int y, int z, TileEntity te, CachedPlane alternateDestination, IMovableRegistry mr) + private void addTile( int x, int y, int z, TileEntity te, CachedPlane alternateDestination, IMovableRegistry mr ) { try { @@ -357,7 +282,7 @@ public class CachedPlane { handler.moveTile( te, this.world, x + this.x_offset, y + this.y_offset, z + this.z_offset ); } - catch (Throwable e) + catch ( Throwable e ) { AELog.error( e ); @@ -384,7 +309,7 @@ public class CachedPlane alternateDestination.addTile( x, y, z, te, null, mr ); } } - catch (Throwable e) + catch ( Throwable e ) { AELog.error( e ); } @@ -394,8 +319,8 @@ public class CachedPlane { // update shit.. - for (int x = 0; x < this.cx_size; x++) - for (int z = 0; z < this.cz_size; z++) + for ( int x = 0; x < this.cx_size; x++ ) + for ( int z = 0; z < this.cz_size; z++ ) { Chunk c = this.myChunks[x][z]; c.resetRelightChecks(); @@ -404,19 +329,87 @@ public class CachedPlane } // send shit... - for (int x = 0; x < this.cx_size; x++) - for (int z = 0; z < this.cz_size; z++) + for ( int x = 0; x < this.cx_size; x++ ) + for ( int z = 0; z < this.cz_size; z++ ) { Chunk c = this.myChunks[x][z]; - for (int y = 1; y < 255; y += 32) + for ( int y = 1; y < 255; y += 32 ) WorldSettings.getInstance().getCompass().updateArea( this.world, c.xPosition << 4, y, c.zPosition << 4 ); Platform.sendChunk( c, this.verticalBits ); - } - } + + class Column + { + + private final int x; + private final int z; + private final Chunk c; + private final Object[] ch = { 0, 0, 0 }; + private final ExtendedBlockStorage[] storage; + private List skipThese = null; + + public Column( Chunk _c, int _x, int _z, int cy, int chunkHeight ) + { + this.x = _x; + this.z = _z; + this.c = _c; + this.storage = this.c.getBlockStorageArray(); + + // make sure storage exists before hand... + for ( int ay = 0; ay < chunkHeight; ay++ ) + { + int by = ( ay + cy ); + ExtendedBlockStorage extendedblockstorage = this.storage[by]; + if ( extendedblockstorage == null ) + extendedblockstorage = this.storage[by] = new ExtendedBlockStorage( by << 4, !this.c.worldObj.provider.hasNoSky ); + } + } + + public void setBlockIDWithMetadata( int y, Object[] blk ) + { + for ( Block matrixFrameBlock : CachedPlane.this.matrixFrame.maybeBlock().asSet() ) + { + if ( blk[0] == matrixFrameBlock ) + { + blk[0] = Platform.AIR; + } + } + + ExtendedBlockStorage extendedBlockStorage = this.storage[y >> 4]; + extendedBlockStorage.func_150818_a( this.x, y & 15, this.z, (Block) blk[0] ); + // extendedBlockStorage.setExtBlockID( x, y & 15, z, blk[0] ); + extendedBlockStorage.setExtBlockMetadata( this.x, y & 15, this.z, (Integer) blk[1] ); + extendedBlockStorage.setExtBlocklightValue( this.x, y & 15, this.z, (Integer) blk[2] ); + } + + public Object[] getDetails( int y ) + { + ExtendedBlockStorage extendedblockstorage = this.storage[y >> 4]; + this.ch[0] = extendedblockstorage.getBlockByExtId( this.x, y & 15, this.z ); + this.ch[1] = extendedblockstorage.getExtBlockMetadata( this.x, y & 15, this.z ); + this.ch[2] = extendedblockstorage.getExtBlocklightValue( this.x, y & 15, this.z ); + return this.ch; + } + + public boolean doNotSkip( int y ) + { + ExtendedBlockStorage extendedblockstorage = this.storage[y >> 4]; + if ( CachedPlane.this.reg.isBlacklisted( extendedblockstorage.getBlockByExtId( this.x, y & 15, this.z ) ) ) + return false; + + return this.skipThese == null || !this.skipThese.contains( y ); + } + + public void setSkip( int yCoord ) + { + if ( this.skipThese == null ) + this.skipThese = new LinkedList(); + this.skipThese.add( yCoord ); + } + } } diff --git a/src/main/java/appeng/spatial/StorageChunkProvider.java b/src/main/java/appeng/spatial/StorageChunkProvider.java index ba94208d5..4cce6d560 100644 --- a/src/main/java/appeng/spatial/StorageChunkProvider.java +++ b/src/main/java/appeng/spatial/StorageChunkProvider.java @@ -18,6 +18,7 @@ package appeng.spatial; + import java.util.ArrayList; import java.util.List; @@ -31,43 +32,42 @@ import net.minecraft.world.gen.ChunkProviderGenerate; import appeng.api.AEApi; import appeng.core.AEConfig; + public class StorageChunkProvider extends ChunkProviderGenerate { + public static final int SQUARE_CHUNK_SIZE = 256; + private final static Block[] BLOCKS; - final static Block[] BLOCKS; - - static { - - BLOCKS = new Block[255 * 256]; - - Block matrixFrame = AEApi.instance().blocks().blockMatrixFrame.block(); - for (int x = 0; x < BLOCKS.length; x++) - BLOCKS[x] = matrixFrame; + static + { + BLOCKS = new Block[255 * SQUARE_CHUNK_SIZE]; + for ( Block matrixFrameBlock : AEApi.instance().definitions().blocks().matrixFrame().maybeBlock().asSet() ) + { + for ( int x = 0; x < BLOCKS.length; x++ ) + { + BLOCKS[x] = matrixFrameBlock; + } + } } - final World w; + final World world; - public StorageChunkProvider(World wrd, long i) { - super( wrd, i, false ); - this.w = wrd; + public StorageChunkProvider( World world, long i ) + { + super( world, i, false ); + this.world = world; } @Override - public boolean unloadQueuedChunks() + public Chunk provideChunk( int x, int z ) { - return true; - } - - @Override - public Chunk provideChunk(int x, int z) - { - Chunk chunk = new Chunk( this.w, BLOCKS, x, z ); + Chunk chunk = new Chunk( this.world, BLOCKS, x, z ); byte[] biomes = chunk.getBiomeArray(); AEConfig config = AEConfig.instance; - for (int k = 0; k < biomes.length; ++k) + for ( int k = 0; k < biomes.length; ++k ) biomes[k] = (byte) config.storageBiomeID; if ( !chunk.isTerrainPopulated ) @@ -80,15 +80,20 @@ public class StorageChunkProvider extends ChunkProviderGenerate } @Override - public void populate(IChunkProvider par1iChunkProvider, int par2, int par3) + public void populate( IChunkProvider par1iChunkProvider, int par2, int par3 ) { } @Override - public List getPossibleCreatures(EnumCreatureType a, int b, int c, int d) + public boolean unloadQueuedChunks() + { + return true; + } + + @Override + public List getPossibleCreatures( EnumCreatureType a, int b, int c, int d ) { return new ArrayList(); } - } diff --git a/src/main/java/appeng/spatial/StorageHelper.java b/src/main/java/appeng/spatial/StorageHelper.java index c5b944c70..aff2b339e 100644 --- a/src/main/java/appeng/spatial/StorageHelper.java +++ b/src/main/java/appeng/spatial/StorageHelper.java @@ -34,7 +34,6 @@ import net.minecraft.world.WorldServer; import appeng.api.AEApi; import appeng.api.util.WorldCoord; -import appeng.block.spatial.BlockMatrixFrame; import appeng.core.stats.Achievements; import appeng.util.Platform; @@ -290,9 +289,10 @@ public class StorageHelper , World dst /** storage cell **/ , int x, int y, int z, int i, int j, int k, int scaleX, int scaleY, int scaleZ) { - BlockMatrixFrame blkMF = (BlockMatrixFrame) AEApi.instance().blocks().blockMatrixFrame.block(); - - this.transverseEdges( i - 1, j - 1, k - 1, i + scaleX + 1, j + scaleY + 1, k + scaleZ + 1, new WrapInMatrixFrame( blkMF, 0, dst ) ); + for ( Block matrixFrameBlock : AEApi.instance().definitions().blocks().matrixFrame().maybeBlock().asSet() ) + { + this.transverseEdges( i - 1, j - 1, k - 1, i + scaleX + 1, j + scaleY + 1, k + scaleZ + 1, new WrapInMatrixFrame( matrixFrameBlock, 0, dst ) ); + } AxisAlignedBB srcBox = AxisAlignedBB.getBoundingBox( x, y, z, x + scaleX + 1, y + scaleY + 1, z + scaleZ + 1 ); diff --git a/src/main/java/appeng/tile/crafting/TileCraftingStorageTile.java b/src/main/java/appeng/tile/crafting/TileCraftingStorageTile.java index 50f5951f1..a0c258b57 100644 --- a/src/main/java/appeng/tile/crafting/TileCraftingStorageTile.java +++ b/src/main/java/appeng/tile/crafting/TileCraftingStorageTile.java @@ -21,25 +21,40 @@ package appeng.tile.crafting; import net.minecraft.item.ItemStack; import appeng.api.AEApi; +import appeng.api.definitions.IBlocks; + public class TileCraftingStorageTile extends TileCraftingTile { - - static final ItemStack STACK_4K_STORAGE = AEApi.instance().blocks().blockCraftingStorage4k.stack( 1 ); - static final ItemStack STACK_16K_STORAGE = AEApi.instance().blocks().blockCraftingStorage16k.stack( 1 ); - static final ItemStack STACK_64K_STORAGE = AEApi.instance().blocks().blockCraftingStorage64k.stack( 1 ); + public static final int KILO_SCALAR = 1024; @Override protected ItemStack getItemFromTile(Object obj) { - int storage = ((TileCraftingTile) obj).getStorageBytes() / 1024; + final IBlocks blocks = AEApi.instance().definitions().blocks(); + final int storage = ((TileCraftingTile) obj).getStorageBytes() / KILO_SCALAR; - if ( storage == 4 ) - return STACK_4K_STORAGE; - if ( storage == 16 ) - return STACK_16K_STORAGE; - if ( storage == 64 ) - return STACK_64K_STORAGE; + switch ( storage ) + { + case 4: + for ( ItemStack stack : blocks.craftingStorage4k().maybeStack( 1 ).asSet() ) + { + return stack; + } + break; + case 16: + for ( ItemStack stack : blocks.craftingStorage16k().maybeStack( 1 ).asSet() ) + { + return stack; + } + break; + case 64: + for ( ItemStack stack : blocks.craftingStorage64k().maybeStack( 1 ).asSet() ) + { + return stack; + } + break; + } return super.getItemFromTile( obj ); } diff --git a/src/main/java/appeng/tile/crafting/TileCraftingTile.java b/src/main/java/appeng/tile/crafting/TileCraftingTile.java index aded1a90f..28c2ba80d 100644 --- a/src/main/java/appeng/tile/crafting/TileCraftingTile.java +++ b/src/main/java/appeng/tile/crafting/TileCraftingTile.java @@ -52,18 +52,22 @@ import appeng.tile.events.TileEventType; import appeng.tile.grid.AENetworkTile; import appeng.util.Platform; + public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IPowerChannelState { - - CraftingCPUCluster cluster; - final CraftingCPUCalculator calc = new CraftingCPUCalculator( this ); + private final CraftingCPUCalculator calc = new CraftingCPUCalculator( this ); public ISimplifiedBundle lightCache; public NBTTagCompound previousState = null; public boolean isCoreBlock = false; + CraftingCPUCluster cluster; - static final ItemStack STACK_CO_PROCESSOR = AEApi.instance().blocks().blockCraftingAccelerator.stack( 1 ); + public TileCraftingTile() + { + this.gridProxy.setFlags( GridFlags.MULTIBLOCK, GridFlags.REQUIRE_CHANNEL ); + this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) ); + } @Override protected AENetworkProxy createProxy() @@ -72,59 +76,39 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP } @Override - protected ItemStack getItemFromTile(Object obj) + protected ItemStack getItemFromTile( Object obj ) { - if ( ((TileCraftingTile) obj).isAccelerator() ) - return STACK_CO_PROCESSOR; + if ( ( (TileCraftingTile) obj ).isAccelerator() ) + { + for ( ItemStack accelerator : AEApi.instance().definitions().blocks().craftingAccelerator().maybeStack( 1 ).asSet() ) + { + return accelerator; + } + } + return super.getItemFromTile( obj ); } - public void updateStatus(CraftingCPUCluster c) + @Override + public boolean canBeRotated() { - if ( this.cluster != null && this.cluster != c ) - this.cluster.breakCluster(); - - this.cluster = c; - this.updateMeta( true ); - } - - public void updateMultiBlock() - { - this.calc.calculateMultiblock( this.worldObj, this.getLocation() ); + return true;// return BlockCraftingUnit.checkType( worldObj.getBlockMetadata( xCoord, yCoord, zCoord ), + // BlockCraftingUnit.BASE_MONITOR ); } @Override - public void setName(String name) + public void setName( String name ) { super.setName( name ); if ( this.cluster != null ) this.cluster.updateName(); } - @TileEvent(TileEventType.WORLD_NBT_WRITE) - public void writeToNBT_TileCraftingTile(NBTTagCompound data) + public boolean isAccelerator() { - data.setBoolean( "core", this.isCoreBlock ); - if ( this.isCoreBlock && this.cluster != null ) - this.cluster.writeToNBT( data ); - } - - @TileEvent(TileEventType.WORLD_NBT_READ) - public void readFromNBT_TileCraftingTile(NBTTagCompound data) - { - this.isCoreBlock = data.getBoolean( "core" ); - if ( this.isCoreBlock ) - { - if ( this.cluster != null ) - this.cluster.readFromNBT( data ); - else - this.previousState = (NBTTagCompound) data.copy(); - } - } - - public TileCraftingTile() { - this.gridProxy.setFlags( GridFlags.MULTIBLOCK, GridFlags.REQUIRE_CHANNEL ); - this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) ); + if ( this.worldObj == null ) + return false; + return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 3 ) == 1; } @Override @@ -135,37 +119,21 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP this.updateMultiBlock(); } - @Override - public boolean canBeRotated() + public void updateMultiBlock() { - return true;// return BlockCraftingUnit.checkType( worldObj.getBlockMetadata( xCoord, yCoord, zCoord ), - // BlockCraftingUnit.BASE_MONITOR ); + this.calc.calculateMultiblock( this.worldObj, this.getLocation() ); } - @Override - public void disconnect(boolean update) + public void updateStatus( CraftingCPUCluster c ) { - if ( this.cluster != null ) - { - this.cluster.destroy(); - if ( update ) - this.updateMeta( true ); - } + if ( this.cluster != null && this.cluster != c ) + this.cluster.breakCluster(); + + this.cluster = c; + this.updateMeta( true ); } - @MENetworkEventSubscribe - public void onPowerStateChange(MENetworkChannelsChanged ev) - { - this.updateMeta( false ); - } - - @MENetworkEventSubscribe - public void onPowerStateChange(MENetworkPowerStatusChange ev) - { - this.updateMeta( false ); - } - - public void updateMeta(boolean updateFormed) + public void updateMeta( boolean updateFormed ) { if ( this.worldObj == null || this.notLoaded() ) return; @@ -177,7 +145,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP power = this.gridProxy.isActive(); int current = this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ); - int newMeta = (current & 3) | (formed ? 8 : 0) | (power ? 4 : 0); + int newMeta = ( current & 3 ) | ( formed ? 8 : 0 ) | ( power ? 4 : 0 ); if ( current != newMeta ) this.worldObj.setBlockMetadataWithNotify( this.xCoord, this.yCoord, this.zCoord, newMeta, 2 ); @@ -191,6 +159,45 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP } } + public boolean isFormed() + { + if ( Platform.isClient() ) + return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 8 ) == 8; + return this.cluster != null; + } + + @TileEvent( TileEventType.WORLD_NBT_WRITE ) + public void writeToNBT_TileCraftingTile( NBTTagCompound data ) + { + data.setBoolean( "core", this.isCoreBlock ); + if ( this.isCoreBlock && this.cluster != null ) + this.cluster.writeToNBT( data ); + } + + @TileEvent( TileEventType.WORLD_NBT_READ ) + public void readFromNBT_TileCraftingTile( NBTTagCompound data ) + { + this.isCoreBlock = data.getBoolean( "core" ); + if ( this.isCoreBlock ) + { + if ( this.cluster != null ) + this.cluster.readFromNBT( data ); + else + this.previousState = (NBTTagCompound) data.copy(); + } + } + + @Override + public void disconnect( boolean update ) + { + if ( this.cluster != null ) + { + this.cluster.destroy(); + if ( update ) + this.updateMeta( true ); + } + } + @Override public IAECluster getCluster() { @@ -203,31 +210,27 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP return true; } - @Override - public boolean isPowered() + @MENetworkEventSubscribe + public void onPowerStateChange( MENetworkChannelsChanged ev ) { - if ( Platform.isClient() ) - return (this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 4) == 4; - return this.gridProxy.isActive(); + this.updateMeta( false ); } - public boolean isFormed() + @MENetworkEventSubscribe + public void onPowerStateChange( MENetworkPowerStatusChange ev ) { - if ( Platform.isClient() ) - return (this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 8) == 8; - return this.cluster != null; - } - - public boolean isAccelerator() - { - if ( this.worldObj == null ) - return false; - return (this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 3) == 1; + this.updateMeta( false ); } public boolean isStatus() { return false; + } @Override + public boolean isPowered() + { + if ( Platform.isClient() ) + return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 4 ) == 4; + return this.gridProxy.isActive(); } public boolean isStorage() @@ -240,14 +243,6 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP return 0; } - @Override - public boolean isActive() - { - if ( Platform.isServer() ) - return this.gridProxy.isActive(); - return this.isPowered() && this.isFormed(); - } - public void breakCluster() { if ( this.cluster != null ) @@ -258,7 +253,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP LinkedList places = new LinkedList(); Iterator i = this.cluster.getTiles(); - while (i.hasNext()) + while ( i.hasNext() ) { IGridHost h = i.next(); if ( h == this ) @@ -267,14 +262,13 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP { TileEntity te = (TileEntity) h; - for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) + for ( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS ) { WorldCoord wc = new WorldCoord( te ); wc.add( d, 1 ); if ( this.worldObj.isAirBlock( wc.x, wc.y, wc.z ) ) places.add( wc ); } - } } @@ -283,11 +277,11 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP if ( places.isEmpty() ) throw new RuntimeException( "No air or even the tile hat was destroyed?!?!" ); - for (IAEItemStack ais : inv.getAvailableItems( AEApi.instance().storage().createItemList() )) + for ( IAEItemStack ais : inv.getAvailableItems( AEApi.instance().storage().createItemList() ) ) { ais = ais.copy(); ais.setStackSize( ais.getItemStack().getMaxStackSize() ); - while (true) + while ( true ) { IAEItemStack g = inv.extractItems( ais.copy(), Actionable.MODULATE, this.cluster.getActionSource() ); if ( g == null ) @@ -298,10 +292,19 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP Platform.spawnDrops( this.worldObj, wc.x, wc.y, wc.z, Collections.singletonList( g.getItemStack() ) ); } - } this.cluster.destroy(); } } + + + + @Override + public boolean isActive() + { + if ( Platform.isServer() ) + return this.gridProxy.isActive(); + return this.isPowered() && this.isFormed(); + } } diff --git a/src/main/java/appeng/tile/crafting/TileMolecularAssembler.java b/src/main/java/appeng/tile/crafting/TileMolecularAssembler.java index 0d6a822bf..d68e059f0 100644 --- a/src/main/java/appeng/tile/crafting/TileMolecularAssembler.java +++ b/src/main/java/appeng/tile/crafting/TileMolecularAssembler.java @@ -18,6 +18,7 @@ package appeng.tile.crafting; + import java.io.IOException; import java.util.ArrayList; @@ -41,6 +42,7 @@ import appeng.api.config.PowerMultiplier; import appeng.api.config.RedstoneMode; import appeng.api.config.Settings; import appeng.api.config.Upgrades; +import appeng.api.definitions.ITileDefinition; import appeng.api.implementations.IPowerChannelState; import appeng.api.implementations.IUpgradeableHost; import appeng.api.implementations.tiles.ICraftingMachine; @@ -61,6 +63,7 @@ import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketAssemblerAnimation; import appeng.items.misc.ItemEncodedPattern; import appeng.me.GridAccessException; +import appeng.parts.automation.DefinitionUpgradeInventory; import appeng.parts.automation.UpgradeInventory; import appeng.tile.TileEvent; import appeng.tile.events.TileEventType; @@ -73,35 +76,50 @@ import appeng.util.InventoryAdaptor; import appeng.util.Platform; import appeng.util.item.AEItemStack; -public class TileMolecularAssembler extends AENetworkInvTile implements IUpgradeableHost, IConfigManagerHost, - IGridTickable, ICraftingMachine, IPowerChannelState + +public class TileMolecularAssembler extends AENetworkInvTile + implements IUpgradeableHost, IConfigManagerHost, IGridTickable, ICraftingMachine, IPowerChannelState { - private static final int[] SIDES = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - private static final ItemStack STACK_ASSEMBLER = AEApi.instance().blocks().blockMolecularAssembler.stack( 1 ); - private final InventoryCrafting craftingInv = new InventoryCrafting( new ContainerNull(), 3, 3 ); + private final InventoryCrafting craftingInv; private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 9 + 2 ); - private final IConfigManager settings = new ConfigManager( this ); - private final UpgradeInventory upgrades = new UpgradeInventory( STACK_ASSEMBLER, this, this.getUpgradeSlots() ); - + private final IConfigManager settings; + private final UpgradeInventory upgrades; + public ISimplifiedBundle lightCache; + private boolean isPowered = false; private ForgeDirection pushDirection = ForgeDirection.UNKNOWN; private ItemStack myPattern = null; private ICraftingPatternDetails myPlan = null; private double progress = 0; private boolean isAwake = false; private boolean forcePlan = false; - private boolean reboot = true; - public ISimplifiedBundle lightCache; + + public TileMolecularAssembler() + { + final ITileDefinition assembler = AEApi.instance().definitions().blocks().molecularAssembler(); + + this.settings = new ConfigManager( this ); + this.settings.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE ); + this.inv.setMaxStackSize( 1 ); + this.gridProxy.setIdlePowerUsage( 0.0 ); + this.upgrades = new DefinitionUpgradeInventory( assembler, this, this.getUpgradeSlots() ); + this.craftingInv = new InventoryCrafting( new ContainerNull(), 3, 3 ); + } + + protected int getUpgradeSlots() + { + return 5; + } @Override - public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table, ForgeDirection where) + public boolean pushPattern( ICraftingPatternDetails patternDetails, InventoryCrafting table, ForgeDirection where ) { if ( this.myPattern == null ) { boolean isEmpty = true; - for (int x = 0; x < this.inv.getSizeInventory(); x++) + for ( int x = 0; x < this.inv.getSizeInventory(); x++ ) isEmpty = this.inv.getStackInSlot( x ) == null && isEmpty; if ( isEmpty && patternDetails.isCraftable() ) @@ -110,7 +128,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade this.myPlan = patternDetails; this.pushDirection = where; - for (int x = 0; x < table.getSizeInventory(); x++) + for ( int x = 0; x < table.getSizeInventory(); x++ ) this.inv.setInventorySlotContents( x, table.getStackInSlot( x ) ); this.updateSleepiness(); @@ -121,6 +139,115 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade return false; } + private void updateSleepiness() + { + boolean wasEnabled = this.isAwake; + this.isAwake = this.myPlan != null && this.hasMats() || this.canPush(); + if ( wasEnabled != this.isAwake ) + { + try + { + if ( this.isAwake ) + this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() ); + else + this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() ); + } + catch ( GridAccessException e ) + { + // :P + } + } + } + + private boolean canPush() + { + return this.inv.getStackInSlot( 9 ) != null; + } + + private boolean hasMats() + { + if ( this.myPlan == null ) + return false; + + for ( int x = 0; x < this.craftingInv.getSizeInventory(); x++ ) + this.craftingInv.setInventorySlotContents( x, this.inv.getStackInSlot( x ) ); + + return this.myPlan.getOutput( this.craftingInv, this.getWorldObj() ) != null; + } + + @Override + public boolean acceptsPlans() + { + return this.inv.getStackInSlot( 10 ) == null; + } + + @Override + public int getInstalledUpgrades( Upgrades u ) + { + return this.upgrades.getInstalledUpgrades( u ); + } + + @TileEvent( TileEventType.NETWORK_READ ) + public boolean readFromStream_TileMolecularAssembler( ByteBuf data ) + { + boolean oldPower = this.isPowered; + this.isPowered = data.readBoolean(); + return this.isPowered != oldPower; + } + + @TileEvent( TileEventType.NETWORK_WRITE ) + public void writeToStream_TileMolecularAssembler( ByteBuf data ) + { + data.writeBoolean( this.isPowered ); + } + + @TileEvent( TileEventType.WORLD_NBT_WRITE ) + public void writeToNBT_TileMolecularAssembler( NBTTagCompound data ) + { + if ( this.forcePlan && this.myPlan != null ) + { + ItemStack pattern = this.myPlan.getPattern(); + if ( pattern != null ) + { + NBTTagCompound compound = new NBTTagCompound(); + pattern.writeToNBT( compound ); + data.setTag( "myPlan", compound ); + data.setInteger( "pushDirection", this.pushDirection.ordinal() ); + } + } + + this.upgrades.writeToNBT( data, "upgrades" ); + this.inv.writeToNBT( data, "inv" ); + this.settings.writeToNBT( data ); + } + + @TileEvent( TileEventType.WORLD_NBT_READ ) + public void readFromNBT_TileMolecularAssembler( NBTTagCompound data ) + { + if ( data.hasKey( "myPlan" ) ) + { + ItemStack myPat = ItemStack.loadItemStackFromNBT( data.getCompoundTag( "myPlan" ) ); + + if ( myPat != null && myPat.getItem() instanceof ItemEncodedPattern ) + { + World w = this.getWorldObj(); + ItemEncodedPattern iep = (ItemEncodedPattern) myPat.getItem(); + ICraftingPatternDetails ph = iep.getPatternForItem( myPat, w ); + if ( ph != null && ph.isCraftable() ) + { + this.forcePlan = true; + this.myPlan = ph; + this.pushDirection = ForgeDirection.getOrientation( data.getInteger( "pushDirection" ) ); + } + } + } + + this.upgrades.readFromNBT( data, "upgrades" ); + this.inv.readFromNBT( data, "inv" ); + this.settings.readFromNBT( data ); + this.recalculatePlan(); + } + private void recalculatePlan() { this.reboot = true; @@ -158,111 +285,50 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade this.updateSleepiness(); } - private void updateSleepiness() + @Override + public AECableType getCableConnectionType( ForgeDirection dir ) { - boolean wasEnabled = this.isAwake; - this.isAwake = this.myPlan != null && this.hasMats() || this.canPush(); - if ( wasEnabled != this.isAwake ) - { - try - { - if ( this.isAwake ) - this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() ); - else - this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() ); - } - catch (GridAccessException e) - { - // :P - } - } - } - - private boolean canPush() - { - return this.inv.getStackInSlot( 9 ) != null; + return AECableType.COVERED; } @Override - public int getInstalledUpgrades(Upgrades u) + public DimensionalCoord getLocation() { - return this.upgrades.getInstalledUpgrades( u ); - } - - protected int getUpgradeSlots() - { - return 5; - } - - @TileEvent(TileEventType.NETWORK_READ) - public boolean readFromStream_TileMolecularAssembler(ByteBuf data) - { - boolean oldPower = this.isPowered; - this.isPowered = data.readBoolean(); - return this.isPowered != oldPower; - } - - @TileEvent(TileEventType.NETWORK_WRITE) - public void writeToStream_TileMolecularAssembler(ByteBuf data) - { - data.writeBoolean( this.isPowered ); - } - - @TileEvent(TileEventType.WORLD_NBT_WRITE) - public void writeToNBT_TileMolecularAssembler(NBTTagCompound data) - { - if ( this.forcePlan && this.myPlan != null ) - { - ItemStack pattern = this.myPlan.getPattern(); - if ( pattern != null ) - { - NBTTagCompound compound = new NBTTagCompound(); - pattern.writeToNBT( compound ); - data.setTag( "myPlan", compound ); - data.setInteger( "pushDirection", this.pushDirection.ordinal() ); - } - } - - this.upgrades.writeToNBT( data, "upgrades" ); - this.inv.writeToNBT( data, "inv" ); - this.settings.writeToNBT( data ); - } - - @TileEvent(TileEventType.WORLD_NBT_READ) - public void readFromNBT_TileMolecularAssembler(NBTTagCompound data) - { - if ( data.hasKey( "myPlan" ) ) - { - ItemStack myPat = ItemStack.loadItemStackFromNBT( data.getCompoundTag( "myPlan" ) ); - - if ( myPat != null && myPat.getItem() instanceof ItemEncodedPattern ) - { - World w = this.getWorldObj(); - ItemEncodedPattern iep = (ItemEncodedPattern) myPat.getItem(); - ICraftingPatternDetails ph = iep.getPatternForItem( myPat, w ); - if ( ph != null && ph.isCraftable() ) - { - this.forcePlan = true; - this.myPlan = ph; - this.pushDirection = ForgeDirection.getOrientation( data.getInteger( "pushDirection" ) ); - } - } - } - - this.upgrades.readFromNBT( data, "upgrades" ); - this.inv.readFromNBT( data, "inv" ); - this.settings.readFromNBT( data ); - this.recalculatePlan(); - } - - public TileMolecularAssembler() { - this.settings.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE ); - this.inv.setMaxStackSize( 1 ); - this.gridProxy.setIdlePowerUsage( 0.0 ); + return new DimensionalCoord( this ); } @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) + public IConfigManager getConfigManager() + { + return this.settings; + } + + @Override + public IInventory getInventoryByName( String name ) + { + if ( name.equals( "upgrades" ) ) + return this.upgrades; + + if ( name.equals( "mac" ) ) + return this.inv; + + return null; + } + + @Override + public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue ) + { + + } + + @Override + public int getInventoryStackLimit() + { + return 1; + } + + @Override + public boolean isItemValidForSlot( int i, ItemStack itemstack ) { if ( i >= 9 ) return false; @@ -273,12 +339,6 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade return false; } - @Override - public boolean acceptsPlans() - { - return this.inv.getStackInSlot( 10 ) == null; - } - private boolean hasPattern() { return this.myPlan != null && this.inv.getStackInSlot( 10 ) != null; @@ -297,71 +357,29 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade } @Override - public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added) + public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added ) { if ( inv == this.inv ) this.recalculatePlan(); } @Override - public int[] getAccessibleSlotsBySide(ForgeDirection whichSide) + public int[] getAccessibleSlotsBySide( ForgeDirection whichSide ) { return SIDES; } - @Override - public AECableType getCableConnectionType(ForgeDirection dir) - { - return AECableType.COVERED; - } - - @Override - public DimensionalCoord getLocation() - { - return new DimensionalCoord( this ); - } - - @Override - public IConfigManager getConfigManager() - { - return this.settings; - } - - @Override - public IInventory getInventoryByName(String name) - { - if ( name.equals( "upgrades" ) ) - return this.upgrades; - - if ( name.equals( "mac" ) ) - return this.inv; - - return null; - } - - @Override - public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue) - { - - } - - @Override - public int getInventoryStackLimit() - { - return 1; - } - public int getCraftingProgress() { return (int) this.progress; } @Override - public void getDrops(World w, int x, int y, int z, ArrayList drops) + public void getDrops( World w, int x, int y, int z, ArrayList drops ) { super.getDrops( w, x, y, z, drops ); - for (int h = 0; h < this.upgrades.getSizeInventory(); h++) + for ( int h = 0; h < this.upgrades.getSizeInventory(); h++ ) { ItemStack is = this.upgrades.getStackInSlot( h ); if ( is != null ) @@ -370,26 +388,15 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade } @Override - public TickingRequest getTickingRequest(IGridNode node) + public TickingRequest getTickingRequest( IGridNode node ) { this.recalculatePlan(); this.updateSleepiness(); return new TickingRequest( 1, 1, !this.isAwake, false ); } - private boolean hasMats() - { - if ( this.myPlan == null ) - return false; - - for (int x = 0; x < this.craftingInv.getSizeInventory(); x++) - this.craftingInv.setInventorySlotContents( x, this.inv.getStackInSlot( x ) ); - - return this.myPlan.getOutput( this.craftingInv, this.getWorldObj() ) != null; - } - @Override - public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) + public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) { if ( this.inv.getStackInSlot( 9 ) != null ) { @@ -419,31 +426,31 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade this.reboot = false; int speed = 10; - switch (this.upgrades.getInstalledUpgrades( Upgrades.SPEED )) + switch ( this.upgrades.getInstalledUpgrades( Upgrades.SPEED ) ) { - case 0: - this.progress += this.userPower( TicksSinceLastCall, speed = 10, 1.0 ); - break; - case 1: - this.progress += this.userPower( TicksSinceLastCall, speed = 13, 1.3 ); - break; - case 2: - this.progress += this.userPower( TicksSinceLastCall, speed = 17, 1.7 ); - break; - case 3: - this.progress += this.userPower( TicksSinceLastCall, speed = 20, 2.0 ); - break; - case 4: - this.progress += this.userPower( TicksSinceLastCall, speed = 25, 2.5 ); - break; - case 5: - this.progress += this.userPower( TicksSinceLastCall, speed = 50, 5.0 ); - break; + case 0: + this.progress += this.userPower( TicksSinceLastCall, speed = 10, 1.0 ); + break; + case 1: + this.progress += this.userPower( TicksSinceLastCall, speed = 13, 1.3 ); + break; + case 2: + this.progress += this.userPower( TicksSinceLastCall, speed = 17, 1.7 ); + break; + case 3: + this.progress += this.userPower( TicksSinceLastCall, speed = 20, 2.0 ); + break; + case 4: + this.progress += this.userPower( TicksSinceLastCall, speed = 25, 2.5 ); + break; + case 5: + this.progress += this.userPower( TicksSinceLastCall, speed = 50, 5.0 ); + break; } if ( this.progress >= 100 ) { - for (int x = 0; x < this.craftingInv.getSizeInventory(); x++) + for ( int x = 0; x < this.craftingInv.getSizeInventory(); x++ ) this.craftingInv.setInventorySlotContents( x, this.inv.getStackInSlot( x ) ); this.progress = 0; @@ -454,7 +461,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade this.pushOut( output.copy() ); - for (int x = 0; x < this.craftingInv.getSizeInventory(); x++) + for ( int x = 0; x < this.craftingInv.getSizeInventory(); x++ ) this.inv.setInventorySlotContents( x, Platform.getContainerItem( this.craftingInv.getStackInSlot( x ) ) ); if ( this.inv.getStackInSlot( 10 ) == null ) @@ -472,7 +479,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade IAEItemStack item = AEItemStack.create( output ); NetworkHandler.instance.sendToAllAround( new PacketAssemblerAnimation( this.xCoord, this.yCoord, this.zCoord, (byte) speed, item ), where ); } - catch (IOException e) + catch ( IOException e ) { // ;P } @@ -490,7 +497,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade { if ( this.inv.getStackInSlot( 9 ) == null ) { - for (int x = 0; x < 9; x++) + for ( int x = 0; x < 9; x++ ) { ItemStack is = this.inv.getStackInSlot( x ); if ( is != null ) @@ -507,23 +514,23 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade } } - private int userPower(int ticksPassed, int bonusValue, double acceleratorTax) + private int userPower( int ticksPassed, int bonusValue, double acceleratorTax ) { try { - return (int) (this.gridProxy.getEnergy().extractAEPower( ticksPassed * bonusValue * acceleratorTax, Actionable.MODULATE, PowerMultiplier.CONFIG ) / acceleratorTax); + return (int) ( this.gridProxy.getEnergy().extractAEPower( ticksPassed * bonusValue * acceleratorTax, Actionable.MODULATE, PowerMultiplier.CONFIG ) / acceleratorTax ); } - catch (GridAccessException e) + catch ( GridAccessException e ) { return 0; } } - private void pushOut(ItemStack output) + private void pushOut( ItemStack output ) { if ( this.pushDirection == ForgeDirection.UNKNOWN ) { - for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) + for ( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS ) output = this.pushTo( output, d ); } else @@ -538,7 +545,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade this.inv.setInventorySlotContents( 9, output ); } - private ItemStack pushTo(ItemStack output, ForgeDirection d) + private ItemStack pushTo( ItemStack output, ForgeDirection d ) { if ( output == null ) return output; @@ -563,10 +570,8 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade return output; } - boolean isPowered = false; - @MENetworkEventSubscribe - public void onPowerEvent(MENetworkPowerStatusChange p) + public void onPowerEvent( MENetworkPowerStatusChange p ) { this.updatePowerState(); } @@ -579,7 +584,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade { newState = this.gridProxy.isActive() && this.gridProxy.getEnergy().extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.0001; } - catch (GridAccessException ignored) + catch ( GridAccessException ignored ) { } @@ -602,5 +607,4 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade { return this.isPowered; } - } diff --git a/src/main/java/appeng/tile/inventory/AppEngInternalInventory.java b/src/main/java/appeng/tile/inventory/AppEngInternalInventory.java index df5f65e6f..5131f054d 100644 --- a/src/main/java/appeng/tile/inventory/AppEngInternalInventory.java +++ b/src/main/java/appeng/tile/inventory/AppEngInternalInventory.java @@ -18,6 +18,7 @@ package appeng.tile.inventory; + import java.util.Iterator; import net.minecraft.entity.player.EntityPlayer; @@ -31,15 +32,23 @@ import appeng.me.storage.MEIInventoryWrapper; import appeng.util.Platform; import appeng.util.iterators.InvIterator; + public class AppEngInternalInventory implements IInventory, Iterable { - protected IAEAppEngInventory te; protected final int size; + protected final ItemStack[] inv; + public boolean enableClientEvents = false; + protected IAEAppEngInventory te; protected int maxStack; - public boolean enableClientEvents = false; - protected final ItemStack[] inv; + public AppEngInternalInventory( IAEAppEngInventory inventory, int size ) + { + this.te = inventory; + this.size = size; + this.maxStack = 64; + this.inv = new ItemStack[size]; + } public IMEInventory getMEInventory() { @@ -54,31 +63,20 @@ public class AppEngInternalInventory implements IInventory, Iterable return true; } - public AppEngInternalInventory(IAEAppEngInventory _te, int s) { - this.te = _te; - this.size = s; - this.maxStack = 64; - this.inv = new ItemStack[s]; - } - - protected boolean eventsEnabled() + @Override + public int getSizeInventory() { - return Platform.isServer() || this.enableClientEvents; - } - - public void setMaxStackSize(int s) - { - this.maxStack = s; + return this.size; } @Override - public ItemStack getStackInSlot(int var1) + public ItemStack getStackInSlot( int var1 ) { return this.inv[var1]; } @Override - public ItemStack decrStackSize(int slot, int qty) + public ItemStack decrStackSize( int slot, int qty ) { if ( this.inv[slot] != null ) { @@ -105,14 +103,19 @@ public class AppEngInternalInventory implements IInventory, Iterable return null; } + protected boolean eventsEnabled() + { + return Platform.isServer() || this.enableClientEvents; + } + @Override - public ItemStack getStackInSlotOnClosing(int var1) + public ItemStack getStackInSlotOnClosing( int var1 ) { return null; } @Override - public void setInventorySlotContents(int slot, ItemStack newItemStack) + public void setInventorySlotContents( int slot, ItemStack newItemStack ) { ItemStack oldStack = this.inv[slot]; this.inv[slot] = newItemStack; @@ -148,106 +151,6 @@ public class AppEngInternalInventory implements IInventory, Iterable } } - @Override - public void markDirty() - { - if ( this.te != null && this.eventsEnabled() ) - { - this.te.onChangeInventory( this, -1, InvOperation.markDirty, null, null ); - } - } - - // for guis... - public void markDirty(int slotIndex) - { - if ( this.te != null && this.eventsEnabled() ) - { - this.te.onChangeInventory( this, slotIndex, InvOperation.markDirty, null, null ); - } - } - - @Override - public int getInventoryStackLimit() - { - return this.maxStack > 64 ? 64 : this.maxStack; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer var1) - { - return true; - } - - @Override - public void closeInventory() - { - } - - @Override - public void openInventory() - { - } - - public void writeToNBT(NBTTagCompound target) - { - for (int x = 0; x < this.size; x++) - { - try - { - NBTTagCompound c = new NBTTagCompound(); - - if ( this.inv[x] != null ) - { - this.inv[x].writeToNBT( c ); - } - - target.setTag( "#" + x, c ); - } - catch (Exception ignored) - { - } - } - } - - public void readFromNBT(NBTTagCompound target) - { - for (int x = 0; x < this.size; x++) - { - try - { - NBTTagCompound c = target.getCompoundTag( "#" + x ); - - if ( c != null ) - this.inv[x] = ItemStack.loadItemStackFromNBT( c ); - - } - catch (Exception e) - { - AELog.error( e ); - } - } - } - - public void writeToNBT(NBTTagCompound data, String name) - { - NBTTagCompound c = new NBTTagCompound(); - this.writeToNBT( c ); - data.setTag( name, c ); - } - - public void readFromNBT(NBTTagCompound data, String name) - { - NBTTagCompound c = data.getCompoundTag( name ); - if ( c != null ) - this.readFromNBT( c ); - } - - @Override - public int getSizeInventory() - { - return this.size; - } - @Override public String getInventoryName() { @@ -261,15 +164,112 @@ public class AppEngInternalInventory implements IInventory, Iterable } @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) + public int getInventoryStackLimit() + { + return this.maxStack > 64 ? 64 : this.maxStack; + } + + @Override + public void markDirty() + { + if ( this.te != null && this.eventsEnabled() ) + { + this.te.onChangeInventory( this, -1, InvOperation.markDirty, null, null ); + } + } + + @Override + public boolean isUseableByPlayer( EntityPlayer var1 ) { return true; } + @Override + public void openInventory() + { + } + + @Override + public void closeInventory() + { + } + + @Override + public boolean isItemValidForSlot( int i, ItemStack itemstack ) + { + return true; + } + + public void setMaxStackSize( int s ) + { + this.maxStack = s; + } + + // for guis... + public void markDirty( int slotIndex ) + { + if ( this.te != null && this.eventsEnabled() ) + { + this.te.onChangeInventory( this, slotIndex, InvOperation.markDirty, null, null ); + } + } + + public void writeToNBT( NBTTagCompound data, String name ) + { + NBTTagCompound c = new NBTTagCompound(); + this.writeToNBT( c ); + data.setTag( name, c ); + } + + public void writeToNBT( NBTTagCompound target ) + { + for ( int x = 0; x < this.size; x++ ) + { + try + { + NBTTagCompound c = new NBTTagCompound(); + + if ( this.inv[x] != null ) + { + this.inv[x].writeToNBT( c ); + } + + target.setTag( "#" + x, c ); + } + catch ( Exception ignored ) + { + } + } + } + + public void readFromNBT( NBTTagCompound data, String name ) + { + NBTTagCompound c = data.getCompoundTag( name ); + if ( c != null ) + this.readFromNBT( c ); + } + + public void readFromNBT( NBTTagCompound target ) + { + for ( int x = 0; x < this.size; x++ ) + { + try + { + NBTTagCompound c = target.getCompoundTag( "#" + x ); + + if ( c != null ) + this.inv[x] = ItemStack.loadItemStackFromNBT( c ); + } + catch ( Exception e ) + { + AELog.error( e ); + } + } + } + @Override public Iterator iterator() { return new InvIterator( this ); } - } diff --git a/src/main/java/appeng/tile/misc/TileCharger.java b/src/main/java/appeng/tile/misc/TileCharger.java index 54b184cce..57e146124 100644 --- a/src/main/java/appeng/tile/misc/TileCharger.java +++ b/src/main/java/appeng/tile/misc/TileCharger.java @@ -34,6 +34,8 @@ import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.config.PowerMultiplier; import appeng.api.config.PowerUnits; +import appeng.api.definitions.IItemDefinition; +import appeng.api.definitions.IMaterials; import appeng.api.implementations.items.IAEItemPowerStorage; import appeng.api.implementations.tiles.ICrankable; import appeng.api.storage.data.IAEItemStack; @@ -124,6 +126,8 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable if ( myItem == null ) return; + final IMaterials materials = AEApi.instance().definitions().materials(); + if ( this.internalCurrentPower > 149 && Platform.isChargeable( myItem ) ) { IAEItemPowerStorage ps = (IAEItemPowerStorage) myItem.getItem(); @@ -138,12 +142,16 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable this.tickTickTimer = 20; // keep ticking... } } - else if ( this.internalCurrentPower > 1499 && AEApi.instance().materials().materialCertusQuartzCrystal.sameAsStack( myItem ) ) + else if ( this.internalCurrentPower > 1499 && materials.certusQuartzCrystal().isSameAs( myItem ) ) { if ( Platform.getRandomFloat() > 0.8f ) // simulate wait { this.extractAEPower( this.internalMaxPower, Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500 - this.setInventorySlotContents( 0, AEApi.instance().materials().materialCertusQuartzCrystalCharged.stack( myItem.stackSize ) ); + + for ( ItemStack charged : materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).asSet() ) + { + this.setInventorySlotContents( 0, charged ); + } } } } @@ -175,10 +183,19 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable this.injectExternalPower( PowerUnits.AE, 150 ); ItemStack myItem = this.getStackInSlot( 0 ); - if ( this.internalCurrentPower > 1499 && AEApi.instance().materials().materialCertusQuartzCrystal.sameAsStack( myItem ) ) + if ( this.internalCurrentPower > 1499 ) { - this.extractAEPower( this.internalMaxPower, Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500 - this.setInventorySlotContents( 0, AEApi.instance().materials().materialCertusQuartzCrystalCharged.stack( myItem.stackSize ) ); + final IMaterials materials = AEApi.instance().definitions().materials(); + + if ( materials.certusQuartzCrystal().isSameAs( myItem ) ) + { + this.extractAEPower( this.internalMaxPower, Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500 + + for ( ItemStack charged : materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).asSet() ) + { + this.setInventorySlotContents( 0, charged ); + } + } } } @@ -215,7 +232,9 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return Platform.isChargeable( itemstack ) || AEApi.instance().materials().materialCertusQuartzCrystal.sameAsStack( itemstack ); + final IItemDefinition cert = AEApi.instance().definitions().materials().certusQuartzCrystal(); + + return Platform.isChargeable( itemstack ) || cert.isSameAs( itemstack ); } @Override @@ -228,7 +247,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable return true; } - return AEApi.instance().materials().materialCertusQuartzCrystalCharged.sameAsStack( extractedItem ); + return AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( extractedItem ); } public void activate(EntityPlayer player) @@ -240,7 +259,8 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable if ( myItem == null ) { ItemStack held = player.inventory.getCurrentItem(); - if ( AEApi.instance().materials().materialCertusQuartzCrystal.sameAsStack( held ) || Platform.isChargeable( held ) ) + + if ( AEApi.instance().definitions().materials().certusQuartzCrystal().isSameAs( held ) || Platform.isChargeable( held ) ) { held = player.inventory.decrStackSize( player.inventory.currentItem, 1 ); this.setInventorySlotContents( 0, held ); diff --git a/src/main/java/appeng/tile/misc/TileCondenser.java b/src/main/java/appeng/tile/misc/TileCondenser.java index bf57095f0..661386416 100644 --- a/src/main/java/appeng/tile/misc/TileCondenser.java +++ b/src/main/java/appeng/tile/misc/TileCondenser.java @@ -30,6 +30,7 @@ import net.minecraftforge.fluids.IFluidHandler; import appeng.api.AEApi; import appeng.api.config.CondenserOutput; import appeng.api.config.Settings; +import appeng.api.definitions.IMaterials; import appeng.api.implementations.items.IStorageComponent; import appeng.api.util.IConfigManager; import appeng.api.util.IConfigurableObject; @@ -102,7 +103,6 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf else break; } - } private boolean canAddOutput(ItemStack output) @@ -130,14 +130,24 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf private ItemStack getOutput() { + final IMaterials materials = AEApi.instance().definitions().materials(); + switch ((CondenserOutput) this.cm.getSetting( Settings.CONDENSER_OUTPUT )) { - case MATTER_BALLS: - return AEApi.instance().materials().materialMatterBall.stack( 1 ); - case SINGULARITY: - return AEApi.instance().materials().materialSingularity.stack( 1 ); - case TRASH: - default: + case MATTER_BALLS: + for ( ItemStack matterBallStack : materials.matterBall().maybeStack( 1 ).asSet() ) + { + return matterBallStack; + } + + case SINGULARITY: + for ( ItemStack singularityStack : materials.singularity().maybeStack( 1 ).asSet() ) + { + return singularityStack; + } + + case TRASH: + default: } return null; } diff --git a/src/main/java/appeng/tile/misc/TileInscriber.java b/src/main/java/appeng/tile/misc/TileInscriber.java index 8311f592c..f5ba6cbcf 100644 --- a/src/main/java/appeng/tile/misc/TileInscriber.java +++ b/src/main/java/appeng/tile/misc/TileInscriber.java @@ -18,6 +18,7 @@ package appeng.tile.misc; + import java.io.IOException; import java.util.ArrayList; import java.util.EnumSet; @@ -34,6 +35,8 @@ import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.config.PowerMultiplier; import appeng.api.config.Upgrades; +import appeng.api.definitions.IComparableDefinition; +import appeng.api.definitions.ITileDefinition; import appeng.api.implementations.IUpgradeableHost; import appeng.api.networking.IGridNode; import appeng.api.networking.energy.IEnergyGrid; @@ -44,7 +47,9 @@ import appeng.api.networking.ticking.TickingRequest; import appeng.api.util.AECableType; import appeng.api.util.IConfigManager; import appeng.core.settings.TickRates; +import appeng.helpers.Reflected; import appeng.me.GridAccessException; +import appeng.parts.automation.DefinitionUpgradeInventory; import appeng.parts.automation.UpgradeInventory; import appeng.recipes.handlers.Inscribe; import appeng.recipes.handlers.Inscribe.InscriberRecipe; @@ -60,57 +65,69 @@ import appeng.util.Platform; import appeng.util.inv.WrapperInventoryRange; import appeng.util.item.AEItemStack; + public class TileInscriber extends AENetworkPowerTile implements IGridTickable, IUpgradeableHost, IConfigManagerHost { + public final int maxProcessingTime = 100; final int[] top = new int[] { 0 }; final int[] bottom = new int[] { 1 }; final int[] sides = new int[] { 2, 3 }; - final AppEngInternalInventory inv = new AppEngInternalInventory( this, 4 ); - - public final int maxProcessingTime = 100; + private final IConfigManager settings; + private final UpgradeInventory upgrades; public int processingTime = 0; - // cycles from 0 - 16, at 8 it preforms the action, at 16 it re-enables the normal routine. public boolean smash; public int finalStep; - public long clientStart; - static final ItemStack STACK_INSCRIBER = AEApi.instance().blocks().blockInscriber.stack( 1 ); - private final IConfigManager settings = new ConfigManager( this ); - private final UpgradeInventory upgrades = new UpgradeInventory( STACK_INSCRIBER, this, this.getUpgradeSlots() ); + @Reflected + public TileInscriber() + { + this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) ); + this.internalMaxPower = 1500; + this.gridProxy.setIdlePowerUsage( 0 ); + this.settings = new ConfigManager( this ); + + final ITileDefinition inscriberDefinition = AEApi.instance().definitions().blocks().inscriber(); + this.upgrades = new DefinitionUpgradeInventory( inscriberDefinition, this, this.getUpgradeSlots() ); + } + + protected int getUpgradeSlots() + { + return 3; + } @Override - public AECableType getCableConnectionType(ForgeDirection dir) + public AECableType getCableConnectionType( ForgeDirection dir ) { return AECableType.COVERED; } - @TileEvent(TileEventType.WORLD_NBT_WRITE) - public void writeToNBT_TileInscriber(NBTTagCompound data) + @TileEvent( TileEventType.WORLD_NBT_WRITE ) + public void writeToNBT_TileInscriber( NBTTagCompound data ) { this.inv.writeToNBT( data, "inscriberInv" ); this.upgrades.writeToNBT( data, "upgrades" ); this.settings.writeToNBT( data ); } - @TileEvent(TileEventType.WORLD_NBT_READ) - public void readFromNBT_TileInscriber(NBTTagCompound data) + @TileEvent( TileEventType.WORLD_NBT_READ ) + public void readFromNBT_TileInscriber( NBTTagCompound data ) { this.inv.readFromNBT( data, "inscriberInv" ); this.upgrades.readFromNBT( data, "upgrades" ); this.settings.readFromNBT( data ); } - @TileEvent(TileEventType.NETWORK_READ) - public boolean readFromStream_TileInscriber(ByteBuf data) throws IOException + @TileEvent( TileEventType.NETWORK_READ ) + public boolean readFromStream_TileInscriber( ByteBuf data ) throws IOException { int slot = data.readByte(); boolean oldSmash = this.smash; - boolean newSmash = (slot & 64) == 64; + boolean newSmash = ( slot & 64 ) == 64; if ( oldSmash != newSmash && newSmash ) { @@ -118,9 +135,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, this.clientStart = System.currentTimeMillis(); } - for (int num = 0; num < this.inv.getSizeInventory(); num++) + for ( int num = 0; num < this.inv.getSizeInventory(); num++ ) { - if ( (slot & (1 << num)) > 0 ) + if ( ( slot & ( 1 << num ) ) > 0 ) this.inv.setInventorySlotContents( num, AEItemStack.loadItemStackFromPacket( data ).getItemStack() ); else this.inv.setInventorySlotContents( num, null ); @@ -129,21 +146,21 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, return false; } - @TileEvent(TileEventType.NETWORK_WRITE) - public void writeToStream_TileInscriber(ByteBuf data) throws IOException + @TileEvent( TileEventType.NETWORK_WRITE ) + public void writeToStream_TileInscriber( ByteBuf data ) throws IOException { int slot = this.smash ? 64 : 0; - for (int num = 0; num < this.inv.getSizeInventory(); num++) + for ( int num = 0; num < this.inv.getSizeInventory(); num++ ) { if ( this.inv.getStackInSlot( num ) != null ) slot |= ( 1 << num ); } data.writeByte( slot ); - for (int num = 0; num < this.inv.getSizeInventory(); num++) + for ( int num = 0; num < this.inv.getSizeInventory(); num++ ) { - if ( (slot & (1 << num)) > 0 ) + if ( ( slot & ( 1 << num ) ) > 0 ) { AEItemStack st = AEItemStack.create( this.inv.getStackInSlot( num ) ); st.writeToPacket( data ); @@ -151,45 +168,33 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, } } + @Override + public void setOrientation( ForgeDirection inForward, ForgeDirection inUp ) + { + super.setOrientation( inForward, inUp ); + this.gridProxy.setValidSides( EnumSet.complementOf( EnumSet.of( this.getForward() ) ) ); + this.setPowerSides( EnumSet.complementOf( EnumSet.of( this.getForward() ) ) ); + } + + @Override + public void getDrops( World w, int x, int y, int z, ArrayList drops ) + { + super.getDrops( w, x, y, z, drops ); + + for ( int h = 0; h < this.upgrades.getSizeInventory(); h++ ) + { + ItemStack is = this.upgrades.getStackInSlot( h ); + if ( is != null ) + drops.add( is ); + } + } + @Override public boolean requiresTESR() { return true; } - public TileInscriber() - { - this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) ); - this.internalMaxPower = 1500; - this.gridProxy.setIdlePowerUsage( 0 ); - } - - @Override - public void setOrientation(ForgeDirection inForward, ForgeDirection inUp) - { - super.setOrientation( inForward, inUp ); - this.gridProxy.setValidSides( EnumSet.complementOf( EnumSet.of( this.getForward() ) ) ); - this.setPowerSides( EnumSet.complementOf( EnumSet.of( this.getForward() ) ) ); - } - - @Override - public IInventory getInternalInventory() - { - return this.inv; - } - - @Override - public int[] getAccessibleSlotsBySide(ForgeDirection d) - { - if ( d == ForgeDirection.UP ) - return this.top; - - if ( d == ForgeDirection.DOWN ) - return this.bottom; - - return this.sides; - } - @Override public int getInventoryStackLimit() { @@ -197,30 +202,24 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, } @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) + public boolean isItemValidForSlot( int i, ItemStack itemstack ) { if ( this.smash ) return false; if ( i == 0 || i == 1 ) { - if ( AEApi.instance().materials().materialNamePress.sameAsStack( itemstack ) ) + if ( AEApi.instance().definitions().materials().namePress().isSameAs( itemstack ) ) + { return true; + } - for (ItemStack s : Inscribe.PLATES ) + for ( ItemStack s : Inscribe.PLATES ) if ( Platform.isSameItemPrecise( s, itemstack ) ) return true; } - if ( i == 2 ) - { - return true; - // for (ItemStack s : Inscribe.inputs) - // if ( Platform.isSameItemPrecise( s, itemstack ) ) - // return true; - } - - return false; + return i == 2; } @Override @@ -233,7 +232,13 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, } @Override - public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added) + public IInventory getInternalInventory() + { + return this.inv; + } + + @Override + public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added ) { try { @@ -248,45 +253,73 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() ); } } - catch (GridAccessException e) + catch ( GridAccessException e ) { // :P } } + @Override + public int[] getAccessibleSlotsBySide( ForgeDirection d ) + { + if ( d == ForgeDirection.UP ) + return this.top; + + if ( d == ForgeDirection.DOWN ) + return this.bottom; + + return this.sides; + } + + @Override + public TickingRequest getTickingRequest( IGridNode node ) + { + return new TickingRequest( TickRates.Inscriber.min, TickRates.Inscriber.max, !this.hasWork(), false ); + } + + private boolean hasWork() + { + if ( this.getTask() != null ) + return true; + + this.processingTime = 0; + return this.smash; + } + public InscriberRecipe getTask() { - ItemStack PlateA = this.getStackInSlot( 0 ); - ItemStack PlateB = this.getStackInSlot( 1 ); + ItemStack plateA = this.getStackInSlot( 0 ); + ItemStack plateB = this.getStackInSlot( 1 ); ItemStack renamedItem = this.getStackInSlot( 2 ); - if ( PlateA != null && PlateA.stackSize > 1 ) + if ( plateA != null && plateA.stackSize > 1 ) return null; - if ( PlateB != null && PlateB.stackSize > 1 ) + if ( plateB != null && plateB.stackSize > 1 ) return null; if ( renamedItem != null && renamedItem.stackSize > 1 ) return null; - boolean isNameA = AEApi.instance().materials().materialNamePress.sameAsStack( PlateA ); - boolean isNameB = AEApi.instance().materials().materialNamePress.sameAsStack( PlateB ); + final IComparableDefinition namePress = AEApi.instance().definitions().materials().namePress(); + boolean isNameA = namePress.isSameAs( plateA ); + boolean isNameB = namePress.isSameAs( plateB ); - if ( (isNameA || isNameB) && (isNameA || PlateA == null) && (isNameB || PlateB == null) ) + if ( ( isNameA || isNameB ) && ( isNameA || plateA == null ) && ( isNameB || plateB == null ) ) { if ( renamedItem != null ) { String name = ""; - if ( PlateA != null ) + if ( plateA != null ) { - NBTTagCompound tag = Platform.openNbtData( PlateA ); + NBTTagCompound tag = Platform.openNbtData( plateA ); name += tag.getString( "InscribeName" ); } - if ( PlateB != null ) + if ( plateB != null ) { - NBTTagCompound tag = Platform.openNbtData( PlateB ); + NBTTagCompound tag = Platform.openNbtData( plateB ); if ( name.length() > 0 ) name += " "; name += tag.getString( "InscribeName" ); @@ -304,49 +337,33 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, else display.removeTag( "Name" ); - return new InscriberRecipe( new ItemStack[] { startingItem }, PlateA, PlateB, renamedItem, false ); + return new InscriberRecipe( new ItemStack[] { startingItem }, plateA, plateB, renamedItem, false ); } } - for (InscriberRecipe i : Inscribe.RECIPES ) + for ( InscriberRecipe i : Inscribe.RECIPES ) { - boolean matchA = (PlateA == null && i.plateA == null) || (Platform.isSameItemPrecise( PlateA, i.plateA )) && // and... - (PlateB == null && i.plateB == null) | (Platform.isSameItemPrecise( PlateB, i.plateB )); + boolean matchA = ( plateA == null && i.plateA == null ) || ( Platform.isSameItemPrecise( plateA, i.plateA ) ) && // and... + ( plateB == null && i.plateB == null ) | ( Platform.isSameItemPrecise( plateB, i.plateB ) ); - boolean matchB = (PlateB == null && i.plateA == null) || (Platform.isSameItemPrecise( PlateB, i.plateA )) && // and... - (PlateA == null && i.plateB == null) | (Platform.isSameItemPrecise( PlateA, i.plateB )); + boolean matchB = ( plateB == null && i.plateA == null ) || ( Platform.isSameItemPrecise( plateB, i.plateA ) ) && // and... + ( plateA == null && i.plateB == null ) | ( Platform.isSameItemPrecise( plateA, i.plateB ) ); if ( matchA || matchB ) { - for (ItemStack option : i.imprintable) + for ( ItemStack option : i.imprintable ) { if ( Platform.isSameItemPrecise( option, this.getStackInSlot( 2 ) ) ) return i; } } - } return null; } - private boolean hasWork() - { - if ( this.getTask() != null ) - return true; - - this.processingTime = 0; - return this.smash; - } - @Override - public TickingRequest getTickingRequest(IGridNode node) - { - return new TickingRequest( TickRates.Inscriber.min, TickRates.Inscriber.max, !this.hasWork(), false ); - } - - @Override - public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) + public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) { if ( this.smash ) { @@ -374,7 +391,6 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, } this.markDirty(); - } else if ( this.finalStep == 16 ) { @@ -413,7 +429,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, this.processingTime += TicksSinceLastCall * speedFactor; } } - catch (GridAccessException e) + catch ( GridAccessException e ) { // :P } @@ -446,7 +462,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, } @Override - public IInventory getInventoryByName(String name) + public IInventory getInventoryByName( String name ) { if ( name.equals( "inv" ) ) return this.inv; @@ -458,31 +474,13 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, } @Override - public int getInstalledUpgrades(Upgrades u) + public int getInstalledUpgrades( Upgrades u ) { return this.upgrades.getInstalledUpgrades( u ); } - protected int getUpgradeSlots() - { - return 3; - } - @Override - public void getDrops(World w, int x, int y, int z, ArrayList drops) - { - super.getDrops( w, x, y, z, drops ); - - for (int h = 0; h < this.upgrades.getSizeInventory(); h++) - { - ItemStack is = this.upgrades.getStackInSlot( h ); - if ( is != null ) - drops.add( is ); - } - } - - @Override - public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue) + public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue ) { } } diff --git a/src/main/java/appeng/tile/networking/TileWireless.java b/src/main/java/appeng/tile/networking/TileWireless.java index 5d082e4ae..d6d5f7b70 100644 --- a/src/main/java/appeng/tile/networking/TileWireless.java +++ b/src/main/java/appeng/tile/networking/TileWireless.java @@ -193,7 +193,7 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi @Override public boolean isItemValidForSlot( int i, ItemStack itemstack ) { - return AEApi.instance().materials().materialWirelessBooster.sameAsStack( itemstack ); + return AEApi.instance().definitions().materials().wirelessBooster().isSameAs( itemstack ); } @Override diff --git a/src/main/java/appeng/tile/qnb/TileQuantumBridge.java b/src/main/java/appeng/tile/qnb/TileQuantumBridge.java index db4ac95d7..f6cbfbc35 100644 --- a/src/main/java/appeng/tile/qnb/TileQuantumBridge.java +++ b/src/main/java/appeng/tile/qnb/TileQuantumBridge.java @@ -18,17 +18,22 @@ package appeng.tile.qnb; + import java.util.EnumSet; import io.netty.buffer.ByteBuf; +import net.minecraft.block.Block; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; +import com.google.common.base.Optional; + import appeng.api.AEApi; +import appeng.api.definitions.IBlockDefinition; import appeng.api.networking.GridFlags; import appeng.api.networking.events.MENetworkEventSubscribe; import appeng.api.networking.events.MENetworkPowerStatusChange; @@ -46,29 +51,32 @@ import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.InvOperation; import appeng.util.Platform; + public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock { - - final private static ItemStack RING_STACK = ( AEApi.instance().blocks().blockQuantumRing != null ) ? AEApi.instance().blocks().blockQuantumRing.stack( 1 ) : null; - + private static final IBlockDefinition RING_DEFINITION = AEApi.instance().definitions().blocks().quantumRing(); + public final byte corner = 16; final int[] sidesRing = new int[] { }; final int[] sidesLink = new int[] { 0 }; - final AppEngInternalInventory internalInventory = new AppEngInternalInventory( this, 1 ); - - public final byte corner = 16; final byte hasSingularity = 32; final byte powered = 64; private final QuantumCalculator calc = new QuantumCalculator( this ); - byte constructed = -1; - - QuantumCluster cluster; public boolean bridgePowered; - + byte constructed = -1; + QuantumCluster cluster; private boolean updateStatus = false; - @TileEvent(TileEventType.TICK) + public TileQuantumBridge() + { + this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) ); + this.gridProxy.setFlags( GridFlags.DENSE_CAPACITY ); + this.gridProxy.setIdlePowerUsage( 22 ); + this.internalInventory.setMaxStackSize( 1 ); + } + + @TileEvent( TileEventType.TICK ) public void onTickEvent() { if ( this.updateStatus ) @@ -80,7 +88,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock } } - @TileEvent(TileEventType.NETWORK_WRITE) + @TileEvent( TileEventType.NETWORK_WRITE ) public void onNetworkWriteEvent( ByteBuf data ) { int out = this.constructed; @@ -94,7 +102,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock data.writeByte( (byte) out ); } - @TileEvent(TileEventType.NETWORK_READ) + @TileEvent( TileEventType.NETWORK_READ ) public boolean onNetworkReadEvent( ByteBuf data ) { int oldValue = this.constructed; @@ -103,19 +111,37 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock return this.constructed != oldValue; } - public TileQuantumBridge() { - this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) ); - this.gridProxy.setFlags( GridFlags.DENSE_CAPACITY ); - this.gridProxy.setIdlePowerUsage( 22 ); - this.internalInventory.setMaxStackSize( 1 ); - } - @Override public IInventory getInternalInventory() { return this.internalInventory; } + @Override + public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added ) + { + if ( this.cluster != null ) + this.cluster.updateStatus( true ); + } + + @Override + public int[] getAccessibleSlotsBySide( ForgeDirection side ) + { + if ( this.isCenter() ) + return this.sidesLink; + return this.sidesRing; + } + + public boolean isCenter() + { + for ( Block link : AEApi.instance().definitions().blocks().quantumLink().maybeBlock().asSet() ) + { + return this.getBlockType() == link; + } + + return false; + } + @MENetworkEventSubscribe public void onPowerStatusChange( MENetworkPowerStatusChange c ) { @@ -123,22 +149,40 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock } @Override - public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added) + public void onReady() { - if ( this.cluster != null ) - this.cluster.updateStatus( true ); + super.onReady(); + + final IBlockDefinition quantumRing = AEApi.instance().definitions().blocks().quantumRing(); + final Optional maybeLinkBlock = quantumRing.maybeBlock(); + final Optional maybeLinkStack = quantumRing.maybeStack( 1 ); + + final boolean isPresent = maybeLinkBlock.isPresent() && maybeLinkStack.isPresent(); + + if ( isPresent && this.getBlockType() == maybeLinkBlock.get() ) + { + final ItemStack linkStack = maybeLinkStack.get(); + + this.gridProxy.setVisualRepresentation( linkStack ); + } } @Override - public int[] getAccessibleSlotsBySide(ForgeDirection side) + public void onChunkUnload() { - if ( this.isCenter() ) - return this.sidesLink; - return this.sidesRing; + this.disconnect( false ); + super.onChunkUnload(); } @Override - public void disconnect(boolean affectWorld) + public void invalidate() + { + this.disconnect( false ); + super.invalidate(); + } + + @Override + public void disconnect( boolean affectWorld ) { if ( this.cluster != null ) { @@ -166,29 +210,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock return !this.isInvalid(); } - @Override - public void onReady() - { - super.onReady(); - if ( this.worldObj.getBlock( this.xCoord, this.yCoord, this.zCoord ) == AEApi.instance().blocks().blockQuantumRing.block() ) - this.gridProxy.setVisualRepresentation( RING_STACK ); - } - - @Override - public void invalidate() - { - this.disconnect( false ); - super.invalidate(); - } - - @Override - public void onChunkUnload() - { - this.disconnect( false ); - super.onChunkUnload(); - } - - public void updateStatus(QuantumCluster c, byte flags, boolean affectWorld) + public void updateStatus( QuantumCluster c, byte flags, boolean affectWorld ) { this.cluster = c; @@ -209,6 +231,25 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock } } + public boolean isCorner() + { + return ( this.constructed & this.corner ) == this.corner && this.constructed != -1; + } + + public EnumSet getConnections() + { + EnumSet set = EnumSet.noneOf( ForgeDirection.class ); + + for ( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS ) + { + TileEntity te = this.worldObj.getTileEntity( this.xCoord + d.offsetX, this.yCoord + d.offsetY, this.zCoord + d.offsetZ ); + if ( te instanceof TileQuantumBridge ) + set.add( d ); + } + + return set; + } + public long getQEFrequency() { ItemStack is = this.internalInventory.getStackInSlot( 0 ); @@ -221,16 +262,6 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock return 0; } - public boolean isCenter() - { - return this.getBlockType() == AEApi.instance().blocks().blockQuantumLink.block(); - } - - public boolean isCorner() - { - return ( this.constructed & this.corner ) == this.corner && this.constructed != -1; - } - public boolean isPowered() { if ( Platform.isClient() ) @@ -240,7 +271,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock { return this.gridProxy.getEnergy().isNetworkPowered(); } - catch (GridAccessException e) + catch ( GridAccessException e ) { // :P } @@ -254,34 +285,20 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock } @Override - public AECableType getCableConnectionType(ForgeDirection dir) + public AECableType getCableConnectionType( ForgeDirection dir ) { return AECableType.DENSE; } - @Override - public DimensionalCoord getLocation() - { - return new DimensionalCoord( this ); - } - public void neighborUpdate() { this.calc.calculateMultiblock( this.worldObj, this.getLocation() ); } - public EnumSet getConnections() + @Override + public DimensionalCoord getLocation() { - EnumSet set = EnumSet.noneOf( ForgeDirection.class ); - - for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity te = this.worldObj.getTileEntity( this.xCoord + d.offsetX, this.yCoord + d.offsetY, this.zCoord + d.offsetZ ); - if ( te instanceof TileQuantumBridge ) - set.add( d ); - } - - return set; + return new DimensionalCoord( this ); } public boolean hasQES() @@ -296,5 +313,4 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock if ( this.cluster != null ) this.cluster.destroy(); } - } diff --git a/src/main/java/appeng/tile/storage/TileIOPort.java b/src/main/java/appeng/tile/storage/TileIOPort.java index 827da4b7d..8ec3901ac 100644 --- a/src/main/java/appeng/tile/storage/TileIOPort.java +++ b/src/main/java/appeng/tile/storage/TileIOPort.java @@ -55,7 +55,9 @@ import appeng.api.util.AECableType; import appeng.api.util.DimensionalCoord; import appeng.api.util.IConfigManager; import appeng.core.settings.TickRates; +import appeng.helpers.Reflected; import appeng.me.GridAccessException; +import appeng.parts.automation.BlockUpgradeInventory; import appeng.parts.automation.UpgradeInventory; import appeng.tile.TileEvent; import appeng.tile.events.TileEventType; @@ -85,27 +87,34 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC private static final int OUTPUT_SLOT_INDEX_BOTTOM_LEFT = 10; private static final int OUTPUT_SLOT_INDEX_BOTTOM_RIGHT = 11; - private final ConfigManager manager = new ConfigManager( this ); + private final ConfigManager manager; private final int[] input = { INPUT_SLOT_INDEX_TOP_LEFT, INPUT_SLOT_INDEX_TOP_RIGHT, INPUT_SLOT_INDEX_CENTER_LEFT, INPUT_SLOT_INDEX_CENTER_RIGHT, INPUT_SLOT_INDEX_BOTTOM_LEFT, INPUT_SLOT_INDEX_BOTTOM_RIGHT }; private final int[] output = { OUTPUT_SLOT_INDEX_TOP_LEFT, OUTPUT_SLOT_INDEX_TOP_RIGHT, OUTPUT_SLOT_INDEX_CENTER_LEFT, OUTPUT_SLOT_INDEX_CENTER_RIGHT, OUTPUT_SLOT_INDEX_BOTTOM_LEFT, OUTPUT_SLOT_INDEX_BOTTOM_RIGHT }; - private final AppEngInternalInventory cells = new AppEngInternalInventory( this, 12 ); - private final UpgradeInventory upgrades = new UpgradeInventory( AEApi.instance().blocks().blockIOPort.block(), this, 3 ); + private final AppEngInternalInventory cells; + private final UpgradeInventory upgrades; - private final BaseActionSource mySrc = new MachineSource( this ); + private final BaseActionSource mySrc; - private YesNo lastRedstoneState = YesNo.UNDECIDED; + private YesNo lastRedstoneState; private ItemStack currentCell; private IMEInventory cachedFluid; private IMEInventory cachedItem; + @Reflected public TileIOPort() { this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL ); + this.manager = new ConfigManager( this ); this.manager.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE ); this.manager.registerSetting( Settings.FULLNESS_MODE, FullnessMode.EMPTY ); this.manager.registerSetting( Settings.OPERATION_MODE, OperationMode.EMPTY ); + this.cells = new AppEngInternalInventory( this, 12 ); + this.mySrc = new MachineSource( this ); + this.lastRedstoneState = YesNo.UNDECIDED; + + this.upgrades = new BlockUpgradeInventory( this.getBlockType(), this, 3 ); } @TileEvent( TileEventType.WORLD_NBT_WRITE ) @@ -123,7 +132,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC this.manager.readFromNBT( data ); this.cells.readFromNBT( data, "cells" ); this.upgrades.readFromNBT( data, "upgrades" ); - if ( data.hasKey( "lastRedstoneState" ) ) + if( data.hasKey( "lastRedstoneState" ) ) this.lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )]; } @@ -143,12 +152,12 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC { try { - if ( this.hasWork() ) + if( this.hasWork() ) this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() ); else this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() ); } - catch ( GridAccessException e ) + catch( GridAccessException e ) { // :P } @@ -157,7 +166,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC public void updateRedstoneState() { YesNo currentState = this.worldObj.isBlockIndirectlyGettingPowered( this.xCoord, this.yCoord, this.zCoord ) ? YesNo.YES : YesNo.NO; - if ( this.lastRedstoneState != currentState ) + if( this.lastRedstoneState != currentState ) { this.lastRedstoneState = currentState; this.updateTask(); @@ -166,7 +175,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC public boolean getRedstoneState() { - if ( this.lastRedstoneState == YesNo.UNDECIDED ) + if( this.lastRedstoneState == YesNo.UNDECIDED ) this.updateRedstoneState(); return this.lastRedstoneState == YesNo.YES; @@ -174,11 +183,11 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC private boolean isEnabled() { - if ( this.getInstalledUpgrades( Upgrades.REDSTONE ) == 0 ) + if( this.getInstalledUpgrades( Upgrades.REDSTONE ) == 0 ) return true; RedstoneMode rs = (RedstoneMode) this.manager.getSetting( Settings.REDSTONE_CONTROLLED ); - if ( rs == RedstoneMode.HIGH_SIGNAL ) + if( rs == RedstoneMode.HIGH_SIGNAL ) return this.getRedstoneState(); return !this.getRedstoneState(); } @@ -192,10 +201,10 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC @Override public IInventory getInventoryByName( String name ) { - if ( name.equals( "upgrades" ) ) + if( name.equals( "upgrades" ) ) return this.upgrades; - if ( name.equals( "cells" ) ) + if( name.equals( "cells" ) ) return this.cells; return null; @@ -209,10 +218,10 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC boolean hasWork() { - if ( this.isEnabled() ) + if( this.isEnabled() ) { - for ( int x = 0; x < 6; x++ ) - if ( this.cells.getStackInSlot( x ) != null ) + for( int x = 0; x < 6; x++ ) + if( this.cells.getStackInSlot( x ) != null ) return true; } @@ -222,9 +231,9 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC @Override public boolean canInsertItem( int slotIndex, ItemStack insertingItem, int side ) { - for ( int inputSlotIndex : this.input ) + for( int inputSlotIndex : this.input ) { - if ( inputSlotIndex == slotIndex ) + if( inputSlotIndex == slotIndex ) { return true; } @@ -236,9 +245,9 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC @Override public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side ) { - for ( int outputSlotIndex : this.output ) + for( int outputSlotIndex : this.output ) { - if ( outputSlotIndex == slotIndex ) + if( outputSlotIndex == slotIndex ) { return true; } @@ -256,7 +265,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC @Override public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added ) { - if ( this.cells == inv ) + if( this.cells == inv ) { this.updateTask(); } @@ -265,7 +274,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC @Override public int[] getAccessibleSlotsBySide( ForgeDirection d ) { - if ( d == ForgeDirection.UP || d == ForgeDirection.DOWN ) + if( d == ForgeDirection.UP || d == ForgeDirection.DOWN ) return this.input; return this.output; @@ -280,12 +289,12 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC @Override public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) { - if ( !this.gridProxy.isActive() ) + if( !this.gridProxy.isActive() ) return TickRateModulation.IDLE; long ItemsToMove = 256; - switch ( this.getInstalledUpgrades( Upgrades.SPEED ) ) + switch( this.getInstalledUpgrades( Upgrades.SPEED ) ) { case 1: ItemsToMove *= 2; @@ -303,32 +312,32 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC IMEInventory itemNet = this.gridProxy.getStorage().getItemInventory(); IMEInventory fluidNet = this.gridProxy.getStorage().getFluidInventory(); IEnergySource energy = this.gridProxy.getEnergy(); - for ( int x = 0; x < 6; x++ ) + for( int x = 0; x < 6; x++ ) { ItemStack is = this.cells.getStackInSlot( x ); - if ( is != null ) + if( is != null ) { - if ( ItemsToMove > 0 ) + if( ItemsToMove > 0 ) { IMEInventory itemInv = this.getInv( is, StorageChannel.ITEMS ); IMEInventory fluidInv = this.getInv( is, StorageChannel.FLUIDS ); - if ( this.manager.getSetting( Settings.OPERATION_MODE ) == OperationMode.EMPTY ) + if( this.manager.getSetting( Settings.OPERATION_MODE ) == OperationMode.EMPTY ) { - if ( itemInv != null ) + if( itemInv != null ) ItemsToMove = this.transferContents( energy, itemInv, itemNet, ItemsToMove, StorageChannel.ITEMS ); - if ( fluidInv != null ) + if( fluidInv != null ) ItemsToMove = this.transferContents( energy, fluidInv, fluidNet, ItemsToMove, StorageChannel.FLUIDS ); } else { - if ( itemInv != null ) + if( itemInv != null ) ItemsToMove = this.transferContents( energy, itemNet, itemInv, ItemsToMove, StorageChannel.ITEMS ); - if ( fluidInv != null ) + if( fluidInv != null ) ItemsToMove = this.transferContents( energy, fluidNet, fluidInv, ItemsToMove, StorageChannel.FLUIDS ); } - if ( ItemsToMove > 0 && this.shouldMove( itemInv, fluidInv ) && !this.moveSlot( x ) ) + if( ItemsToMove > 0 && this.shouldMove( itemInv, fluidInv ) && !this.moveSlot( x ) ) return TickRateModulation.IDLE; return TickRateModulation.URGENT; @@ -338,7 +347,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC } } } - catch ( GridAccessException e ) + catch( GridAccessException e ) { return TickRateModulation.IDLE; } @@ -355,14 +364,14 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC private IMEInventory getInv( ItemStack is, StorageChannel chan ) { - if ( this.currentCell != is ) + if( this.currentCell != is ) { this.currentCell = is; this.cachedFluid = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.FLUIDS ); this.cachedItem = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS ); } - if ( StorageChannel.ITEMS == chan ) + if( StorageChannel.ITEMS == chan ) return this.cachedItem; return this.cachedFluid; @@ -371,7 +380,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC private long transferContents( IEnergySource energy, IMEInventory src, IMEInventory destination, long itemsToMove, StorageChannel chan ) { IItemList myList; - if ( src instanceof IMEMonitor ) + if( src instanceof IMEMonitor ) myList = ( (IMEMonitor) src ).getStorageList(); else myList = src.getAvailableItems( src.getChannel().createList() ); @@ -382,37 +391,37 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC { didStuff = false; - for ( IAEStack s : myList ) + for( IAEStack s : myList ) { long totalStackSize = s.getStackSize(); - if ( totalStackSize > 0 ) + if( totalStackSize > 0 ) { IAEStack stack = destination.injectItems( s, Actionable.SIMULATE, this.mySrc ); long possible = 0; - if ( stack == null ) + if( stack == null ) possible = totalStackSize; else possible = totalStackSize - stack.getStackSize(); - if ( possible > 0 ) + if( possible > 0 ) { possible = Math.min( possible, itemsToMove ); s.setStackSize( possible ); IAEStack extracted = src.extractItems( s, Actionable.MODULATE, this.mySrc ); - if ( extracted != null ) + if( extracted != null ) { possible = extracted.getStackSize(); IAEStack failed = Platform.poweredInsert( energy, destination, extracted, this.mySrc ); - if ( failed != null ) + if( failed != null ) { possible -= failed.getStackSize(); src.injectItems( failed, Actionable.MODULATE, this.mySrc ); } - if ( possible > 0 ) + if( possible > 0 ) { itemsToMove -= possible; didStuff = true; @@ -424,7 +433,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC } } } - while ( itemsToMove > 0 && didStuff ); + while( itemsToMove > 0 && didStuff ); return itemsToMove; } @@ -433,11 +442,11 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC { FullnessMode fm = (FullnessMode) this.manager.getSetting( Settings.FULLNESS_MODE ); - if ( itemInv != null && fluidInv != null ) + if( itemInv != null && fluidInv != null ) return this.matches( fm, itemInv ) && this.matches( fm, fluidInv ); - else if ( itemInv != null ) + else if( itemInv != null ) return this.matches( fm, itemInv ); - else if ( fluidInv != null ) + else if( fluidInv != null ) return this.matches( fm, fluidInv ); return true; @@ -448,7 +457,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC WrapperInventoryRange wir = new WrapperInventoryRange( this, this.output, true ); ItemStack result = InventoryAdaptor.getAdaptor( wir, ForgeDirection.UNKNOWN ).addItems( this.getStackInSlot( x ) ); - if ( result == null ) + if( result == null ) { this.setInventorySlotContents( x, null ); return true; @@ -459,21 +468,21 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC private boolean matches( FullnessMode fm, IMEInventory src ) { - if ( fm == FullnessMode.HALF ) + if( fm == FullnessMode.HALF ) return true; IItemList myList; - if ( src instanceof IMEMonitor ) + if( src instanceof IMEMonitor ) myList = ( (IMEMonitor) src ).getStorageList(); else myList = src.getAvailableItems( src.getChannel().createList() ); - if ( fm == FullnessMode.EMPTY ) + if( fm == FullnessMode.EMPTY ) return myList.isEmpty(); IAEStack test = myList.getFirstItem(); - if ( test != null ) + if( test != null ) { test.setStackSize( 1 ); return src.injectItems( test, Actionable.SIMULATE, this.mySrc ) != null; @@ -495,11 +504,11 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC { super.getDrops( w, x, y, z, drops ); - for ( int upgradeIndex = 0; upgradeIndex < this.upgrades.getSizeInventory(); upgradeIndex++ ) + for( int upgradeIndex = 0; upgradeIndex < this.upgrades.getSizeInventory(); upgradeIndex++ ) { ItemStack stackInSlot = this.upgrades.getStackInSlot( upgradeIndex ); - if ( stackInSlot != null ) + if( stackInSlot != null ) { drops.add( stackInSlot ); } diff --git a/src/main/java/appeng/transformer/annotations/Integration.java b/src/main/java/appeng/transformer/annotations/Integration.java index 267d3c479..3410d42f9 100644 --- a/src/main/java/appeng/transformer/annotations/Integration.java +++ b/src/main/java/appeng/transformer/annotations/Integration.java @@ -34,6 +34,7 @@ public @interface Integration Interface[] value(); } + @Retention( RetentionPolicy.RUNTIME ) @Target( ElementType.TYPE ) @interface Interface @@ -43,10 +44,11 @@ public @interface Integration String iname(); } + @Retention( RetentionPolicy.RUNTIME ) @Target( ElementType.METHOD ) @interface Method { String iname(); } -} +} \ No newline at end of file diff --git a/src/main/java/appeng/util/ConfigManager.java b/src/main/java/appeng/util/ConfigManager.java index 85bd76dc5..b807d6595 100644 --- a/src/main/java/appeng/util/ConfigManager.java +++ b/src/main/java/appeng/util/ConfigManager.java @@ -18,95 +18,46 @@ package appeng.util; -import java.util.HashMap; + +import java.util.EnumMap; +import java.util.Map; import java.util.Set; import net.minecraft.nbt.NBTTagCompound; import appeng.api.config.LevelEmitterMode; +import appeng.api.config.Settings; import appeng.api.config.StorageFilter; import appeng.api.util.IConfigManager; import appeng.core.AELog; -public class ConfigManager implements IConfigManager + +public final class ConfigManager implements IConfigManager { + private final Map> settings = new EnumMap>( Settings.class ); + private final IConfigManagerHost target; - final HashMap Settings = new HashMap(); - final IConfigManagerHost target; - - public ConfigManager(IConfigManagerHost tile) { + public ConfigManager( IConfigManagerHost tile ) + { this.target = tile; } - /** - * read all settings using config manager. - * - * @param tagCompound to be read from compound - */ @Override - public void readFromNBT(NBTTagCompound tagCompound) + public Set getSettings() { - for (Enum key : this.Settings.keySet()) - { - try - { - if ( tagCompound.hasKey( key.name() ) ) - { - String value = tagCompound.getString( key.name() ); - - // Provides an upgrade path for the rename of this value in the API between rv1 and rv2 - if( value.equals( "EXTACTABLE_ONLY" ) ){ - value = StorageFilter.EXTRACTABLE_ONLY.toString(); - } else if( value.equals( "STOREABLE_AMOUNT" ) ) { - value = LevelEmitterMode.STORABLE_AMOUNT.toString(); - } - - Enum oldValue = this.Settings.get( key ); - - Enum newValue = Enum.valueOf( oldValue.getClass(), value ); - - this.putSetting( key, newValue ); - } - } - catch (IllegalArgumentException e) - { - AELog.error( e ); - } - } - } - - /** - * save all settings using config manager. - * - * @param destination to be written to compound - */ - @Override - public void writeToNBT(NBTTagCompound destination ) - { - - for (Enum e : this.Settings.keySet()) - { - destination.setString( e.name(), this.Settings.get( e ).toString() ); - } - + return this.settings.keySet(); } @Override - public Set getSettings() + public void registerSetting( Settings settingName, Enum defaultValue ) { - return this.Settings.keySet(); + this.settings.put( settingName, defaultValue ); } @Override - public void registerSetting(Enum settingName, Enum defaultValue) + public Enum getSetting( Settings settingName ) { - this.Settings.put( settingName, defaultValue ); - } - - @Override - public Enum getSetting(Enum settingName) - { - Enum oldValue = this.Settings.get( settingName ); + Enum oldValue = this.settings.get( settingName ); if ( oldValue != null ) return oldValue; @@ -115,12 +66,66 @@ public class ConfigManager implements IConfigManager } @Override - public Enum putSetting(Enum settingName, Enum newValue) + public Enum putSetting( Settings settingName, Enum newValue ) { - Enum oldValue = this.getSetting( settingName ); - this.Settings.put( settingName, newValue ); + Enum oldValue = this.getSetting( settingName ); + this.settings.put( settingName, newValue ); this.target.updateSetting( this, settingName, newValue ); return oldValue; } + /** + * save all settings using config manager. + * + * @param tagCompound to be written to compound + */ + @Override + public void writeToNBT( NBTTagCompound tagCompound ) + { + + for ( Settings setting : this.settings.keySet() ) + { + tagCompound.setString( setting.name(), this.settings.get( setting ).toString() ); + } + } + + /** + * read all settings using config manager. + * + * @param tagCompound to be read from compound + */ + @Override + public void readFromNBT( NBTTagCompound tagCompound ) + { + for ( Settings key : this.settings.keySet() ) + { + try + { + if ( tagCompound.hasKey( key.name() ) ) + { + String value = tagCompound.getString( key.name() ); + + // Provides an upgrade path for the rename of this value in the API between rv1 and rv2 + if ( value.equals( "EXTACTABLE_ONLY" ) ) + { + value = StorageFilter.EXTRACTABLE_ONLY.toString(); + } + else if ( value.equals( "STOREABLE_AMOUNT" ) ) + { + value = LevelEmitterMode.STORABLE_AMOUNT.toString(); + } + + Enum oldValue = this.settings.get( key ); + + Enum newValue = Enum.valueOf( oldValue.getClass(), value ); + + this.putSetting( key, newValue ); + } + } + catch ( IllegalArgumentException e ) + { + AELog.error( e ); + } + } + } } diff --git a/src/main/java/appeng/util/Platform.java b/src/main/java/appeng/util/Platform.java index 032fac1f3..cae14a36c 100644 --- a/src/main/java/appeng/util/Platform.java +++ b/src/main/java/appeng/util/Platform.java @@ -69,7 +69,6 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.StatCollector; import net.minecraft.util.Vec3; -import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraft.world.chunk.Chunk; @@ -95,6 +94,9 @@ import appeng.api.config.PowerUnits; import appeng.api.config.SearchBoxMode; import appeng.api.config.SecurityPermissions; import appeng.api.config.SortOrder; +import appeng.api.definitions.IItemDefinition; +import appeng.api.definitions.IMaterials; +import appeng.api.definitions.IParts; import appeng.api.implementations.items.IAEItemPowerStorage; import appeng.api.implementations.items.IAEWrench; import appeng.api.implementations.tiles.ITileStorageMonitorable; @@ -118,7 +120,6 @@ import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAETagCompound; import appeng.api.storage.data.IItemList; import appeng.api.util.AEColor; -import appeng.api.util.AEItemDefinition; import appeng.api.util.DimensionalCoord; import appeng.core.AEConfig; import appeng.core.AELog; @@ -1007,10 +1008,7 @@ public class Platform return null; // wtf? } - public static boolean blockAtLocationIs(IBlockAccess w, int x, int y, int z, AEItemDefinition def) - { - return def.block() == w.getBlock( x, y, z ); - } + public static ForgeDirection rotateAround(ForgeDirection forward, ForgeDirection axis) { @@ -1134,9 +1132,9 @@ public class Platform return false; } - public static boolean isSameItem(ItemStack ol, ItemStack op) + public static boolean isSameItem(ItemStack left, ItemStack right) { - return ol != null && op != null && ol.isItemEqual( op ); + return left != null && right != null && left.isItemEqual( right ); } public static ItemStack cloneItemStack(ItemStack a) @@ -1765,7 +1763,11 @@ public class Platform return false; if ( type == AEFeature.CertusQuartzTools ) - return AEApi.instance().materials().materialCertusQuartzCrystal.sameAsStack( b ); + { + final IItemDefinition certusQuartzCrystal = AEApi.instance().definitions().materials().certusQuartzCrystal(); + + return certusQuartzCrystal.isSameAs( b ); + } if ( type == AEFeature.NetherQuartzTools ) return Items.quartz == b.getItem(); @@ -1775,19 +1777,29 @@ public class Platform public static Object findPreferred(ItemStack[] is) { + final IParts parts = AEApi.instance().definitions().parts(); + for (ItemStack stack : is) { - if ( AEApi.instance().parts().partCableGlass.sameAs( AEColor.Transparent, stack ) ) + if ( parts.cableGlass().sameAs( AEColor.Transparent, stack ) ) + { return stack; + } - if ( AEApi.instance().parts().partCableCovered.sameAs( AEColor.Transparent, stack ) ) + if ( parts.cableCovered().sameAs( AEColor.Transparent, stack ) ) + { return stack; + } - if ( AEApi.instance().parts().partCableSmart.sameAs( AEColor.Transparent, stack ) ) + if ( parts.cableSmart().sameAs( AEColor.Transparent, stack ) ) + { return stack; + } - if ( AEApi.instance().parts().partCableDense.sameAs( AEColor.Transparent, stack ) ) + if ( parts.cableDense().sameAs( AEColor.Transparent, stack ) ) + { return stack; + } } return is; @@ -1875,8 +1887,12 @@ public class Platform public static boolean isRecipePrioritized(ItemStack what) { - return AEApi.instance().materials().materialPurifiedCertusQuartzCrystal.sameAsStack( what ) - || AEApi.instance().materials().materialPurifiedFluixCrystal.sameAsStack( what ) - || AEApi.instance().materials().materialPurifiedNetherQuartzCrystal.sameAsStack( what ); + final IMaterials materials = AEApi.instance().definitions().materials(); + + boolean isPurified = materials.purifiedCertusQuartzCrystal().isSameAs( what ); + isPurified |= materials.purifiedFluixCrystal().isSameAs( what ); + isPurified |= materials.purifiedNetherQuartzCrystal().isSameAs( what ); + + return isPurified; } } diff --git a/src/main/java/appeng/util/item/AEItemStack.java b/src/main/java/appeng/util/item/AEItemStack.java index 7b682d88b..7538236c0 100644 --- a/src/main/java/appeng/util/item/AEItemStack.java +++ b/src/main/java/appeng/util/item/AEItemStack.java @@ -40,6 +40,7 @@ import cpw.mods.fml.relauncher.SideOnly; import appeng.api.config.FuzzyMode; import appeng.api.storage.StorageChannel; import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAETagCompound; import appeng.util.Platform; @@ -113,13 +114,14 @@ public final class AEItemStack extends AEStack implements IAEItemS this.def.isOre = OreHelper.INSTANCE.isOre( is ); } - public static AEItemStack create(Object a) + public static AEItemStack create( ItemStack stack ) { - if ( a instanceof ItemStack ) - return new AEItemStack( (ItemStack) a ); - if ( a instanceof IAEItemStack ) - ((IAEItemStack) a).copy(); - return null; + return new AEItemStack( stack ); + } + + public static IAEStack create( IAEStack stack ) + { + return stack.copy(); } @Override diff --git a/src/main/java/appeng/worldgen/MeteoritePlacer.java b/src/main/java/appeng/worldgen/MeteoritePlacer.java new file mode 100644 index 000000000..80738d67d --- /dev/null +++ b/src/main/java/appeng/worldgen/MeteoritePlacer.java @@ -0,0 +1,513 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.worldgen; + + +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.oredict.OreDictionary; + +import appeng.api.AEApi; +import appeng.api.definitions.IBlockDefinition; +import appeng.api.definitions.IBlocks; +import appeng.api.definitions.IMaterials; +import appeng.core.AEConfig; +import appeng.core.WorldSettings; +import appeng.core.features.AEFeature; +import appeng.worldgen.meteorite.Fallout; +import appeng.worldgen.meteorite.FalloutCopy; +import appeng.worldgen.meteorite.FalloutSand; +import appeng.worldgen.meteorite.FalloutSnow; +import appeng.worldgen.meteorite.IMeteoriteWorld; +import appeng.worldgen.meteorite.MeteoriteBlockPutter; +import appeng.util.InventoryAdaptor; +import appeng.util.Platform; + + +public final class MeteoritePlacer +{ + public static final double PRESSES_SPAWN_CHANCE = 0.7; + public static final int SKYSTONE_SPAWN_LIMIT = 12; + private final Collection validSpawn = new HashSet(); + private final Collection invalidSpawn = new HashSet(); + private final IBlockDefinition skyChestDefinition; + private final IBlockDefinition skyStoneDefinition; + private final MeteoriteBlockPutter putter = new MeteoriteBlockPutter(); + private double meteoriteSize = ( Math.random() * 6.0 ) + 2; + private double realCrater = this.meteoriteSize * 2 + 5; + private double squaredMeteoriteSize = this.meteoriteSize * this.meteoriteSize; + private double crater = this.realCrater * this.realCrater; + private NBTTagCompound settings; + private Fallout type; + + public MeteoritePlacer() + { + final IBlocks blocks = AEApi.instance().definitions().blocks(); + + this.skyChestDefinition = blocks.skyChest(); + this.skyStoneDefinition = blocks.skyStone(); + + this.validSpawn.add( Blocks.stone ); + this.validSpawn.add( Blocks.cobblestone ); + this.validSpawn.add( Blocks.grass ); + this.validSpawn.add( Blocks.sand ); + this.validSpawn.add( Blocks.dirt ); + this.validSpawn.add( Blocks.gravel ); + this.validSpawn.add( Blocks.netherrack ); + this.validSpawn.add( Blocks.iron_ore ); + this.validSpawn.add( Blocks.gold_ore ); + this.validSpawn.add( Blocks.diamond_ore ); + this.validSpawn.add( Blocks.redstone_ore ); + this.validSpawn.add( Blocks.hardened_clay ); + this.validSpawn.add( Blocks.ice ); + this.validSpawn.add( Blocks.snow ); + + for ( Block skyStoneBlock : this.skyStoneDefinition.maybeBlock().asSet() ) + { + this.invalidSpawn.add( skyStoneBlock ); + } + this.invalidSpawn.add( Blocks.planks ); + this.invalidSpawn.add( Blocks.iron_door ); + this.invalidSpawn.add( Blocks.iron_bars ); + this.invalidSpawn.add( Blocks.wooden_door ); + this.invalidSpawn.add( Blocks.brick_block ); + this.invalidSpawn.add( Blocks.clay ); + this.invalidSpawn.add( Blocks.water ); + this.invalidSpawn.add( Blocks.log ); + this.invalidSpawn.add( Blocks.log2 ); + + this.type = new Fallout( this.putter, this.skyStoneDefinition ); + } + + public boolean spawnMeteorite( IMeteoriteWorld w, NBTTagCompound meteoriteBlob ) + { + this.settings = meteoriteBlob; + + int x = this.settings.getInteger( "x" ); + int y = this.settings.getInteger( "y" ); + int z = this.settings.getInteger( "z" ); + + this.meteoriteSize = this.settings.getDouble( "real_sizeOfMeteorite" ); + this.realCrater = this.settings.getDouble( "realCrater" ); + this.squaredMeteoriteSize = this.settings.getDouble( "sizeOfMeteorite" ); + this.crater = this.settings.getDouble( "crater" ); + + Block blk = Block.getBlockById( this.settings.getInteger( "blk" ) ); + + if ( blk == Blocks.sand ) + this.type = new FalloutSand( w, x, y, z, this.putter, this.skyStoneDefinition ); + else if ( blk == Blocks.hardened_clay ) + this.type = new FalloutCopy( w, x, y, z, this.putter, this.skyStoneDefinition ); + else if ( blk == Blocks.ice || blk == Blocks.snow ) + this.type = new FalloutSnow( w, x, y, z, this.putter, this.skyStoneDefinition ); + + int skyMode = this.settings.getInteger( "skyMode" ); + + // creator + if ( skyMode > 10 ) + this.placeCrater( w, x, y, z ); + + this.placeMeteorite( w, x, y, z ); + + // collapse blocks... + if ( skyMode > 3 ) + this.decay( w, x, y, z ); + + w.done(); + return true; + } + + private void placeCrater( IMeteoriteWorld w, int x, int y, int z ) + { + boolean lava = this.settings.getBoolean( "lava" ); + + int maxY = 255; + int minX = w.minX( x - 200 ); + int maxX = w.maxX( x + 200 ); + int minZ = w.minZ( z - 200 ); + int maxZ = w.maxZ( z + 200 ); + + for ( int j = y - 5; j < maxY; j++ ) + { + boolean changed = false; + + for ( int i = minX; i < maxX; i++ ) + for ( int k = minZ; k < maxZ; k++ ) + { + double dx = i - x; + double dz = k - z; + double h = y - this.meteoriteSize + 1 + this.type.adjustCrater(); + + double distanceFrom = dx * dx + dz * dz; + + if ( j > h + distanceFrom * 0.02 ) + { + if ( lava && j < y && w.getBlock( x, y - 1, z ).isBlockSolid( w.getWorld(), i, j, k, 0 ) ) + { + if ( j > h + distanceFrom * 0.02 ) + this.putter.put( w, i, j, k, Blocks.lava ); + } + else + changed = this.putter.put( w, i, j, k, Platform.AIR ) || changed; + } + } + } + + for ( Object o : w.getWorld().getEntitiesWithinAABB( EntityItem.class, AxisAlignedBB.getBoundingBox( w.minX( x - 30 ), y - 5, w.minZ( z - 30 ), w.maxX( x + 30 ), y + 30, w.maxZ( z + 30 ) ) ) ) + { + Entity e = (Entity) o; + e.setDead(); + } + } + + private void placeMeteorite( IMeteoriteWorld w, int x, int y, int z ) + { + int meteorXLength = w.minX( x - 8 ); + int meteorXHeight = w.maxX( x + 8 ); + int meteorZLength = w.minZ( z - 8 ); + int meteorZHeight = w.maxZ( z + 8 ); + + // spawn meteor + for ( int i = meteorXLength; i < meteorXHeight; i++ ) + for ( int j = y - 8; j < y + 8; j++ ) + for ( int k = meteorZLength; k < meteorZHeight; k++ ) + { + double dx = i - x; + double dy = j - y; + double dz = k - z; + + if ( dx * dx * 0.7 + dy * dy * ( j > y ? 1.4 : 0.8 ) + dz * dz * 0.7 < this.squaredMeteoriteSize ) + { + for ( Block skyStoneBlock : this.skyStoneDefinition.maybeBlock().asSet() ) + { + this.putter.put( w, i, j, k, skyStoneBlock ); + } + } + } + + if ( AEConfig.instance.isFeatureEnabled( AEFeature.SpawnPressesInMeteorites ) ) + { + for ( Block skyChestBlock : this.skyChestDefinition.maybeBlock().asSet() ) + { + this.putter.put( w, x, y, z, skyChestBlock ); + } + + TileEntity te = w.getTileEntity( x, y, z ); + if ( te instanceof IInventory ) + { + InventoryAdaptor ap = InventoryAdaptor.getAdaptor( te, ForgeDirection.UP ); + + int primary = Math.max( 1, (int) ( Math.random() * 4 ) ); + + if ( primary > 3 ) // in case math breaks... + primary = 3; + + for ( int zz = 0; zz < primary; zz++ ) + { + int r = 0; + boolean duplicate = false; + + do + { + duplicate = false; + + if ( Math.random() > PRESSES_SPAWN_CHANCE ) + r = WorldSettings.getInstance().getNextOrderedValue( "presses" ); + else + r = (int) ( Math.random() * 1000 ); + + ItemStack toAdd = null; + final IMaterials materials = AEApi.instance().definitions().materials(); + + switch ( r % 4 ) + { + case 0: + for ( ItemStack calc : materials.calcProcessorPress().maybeStack( 1 ).asSet() ) + { + toAdd = calc; + } + break; + case 1: + for ( ItemStack calc : materials.engProcessorPress().maybeStack( 1 ).asSet() ) + { + toAdd = calc; + } + break; + case 2: + for ( ItemStack calc : materials.logicProcessorPress().maybeStack( 1 ).asSet() ) + { + toAdd = calc; + } + break; + case 3: + for ( ItemStack calc : materials.siliconPress().maybeStack( 1 ).asSet() ) + { + toAdd = calc; + } + break; + default: + } + + if ( toAdd != null ) + { + if ( ap.simulateRemove( 1, toAdd, null ) == null ) + ap.addItems( toAdd ); + else + duplicate = true; + } + } + while ( duplicate ); + } + + int secondary = Math.max( 1, (int) ( Math.random() * 3 ) ); + for ( int zz = 0; zz < secondary; zz++ ) + { + switch ( (int) ( Math.random() * 1000 ) % 3 ) + { + case 0: + final int amount = (int) ( ( Math.random() * SKYSTONE_SPAWN_LIMIT ) + 1 ); + for ( ItemStack skyStoneStack : this.skyStoneDefinition.maybeStack( amount ).asSet() ) + { + ap.addItems( skyStoneStack ); + } + break; + case 1: + List possibles = new LinkedList(); + possibles.addAll( OreDictionary.getOres( "nuggetIron" ) ); + possibles.addAll( OreDictionary.getOres( "nuggetCopper" ) ); + possibles.addAll( OreDictionary.getOres( "nuggetTin" ) ); + possibles.addAll( OreDictionary.getOres( "nuggetSilver" ) ); + possibles.addAll( OreDictionary.getOres( "nuggetLead" ) ); + possibles.addAll( OreDictionary.getOres( "nuggetPlatinum" ) ); + possibles.addAll( OreDictionary.getOres( "nuggetNickel" ) ); + possibles.addAll( OreDictionary.getOres( "nuggetAluminium" ) ); + possibles.addAll( OreDictionary.getOres( "nuggetElectrum" ) ); + possibles.add( new ItemStack( net.minecraft.init.Items.gold_nugget ) ); + + ItemStack nugget = Platform.pickRandom( possibles ); + if ( nugget != null ) + { + nugget = nugget.copy(); + nugget.stackSize = (int) ( Math.random() * 12 ) + 1; + ap.addItems( nugget ); + } + break; + } + } + } + } + } + + private void decay( IMeteoriteWorld w, int x, int y, int z ) + { + double randomShit = 0; + + int meteorXLength = w.minX( x - 30 ); + int meteorXHeight = w.maxX( x + 30 ); + int meteorZLength = w.minZ( z - 30 ); + int meteorZHeight = w.maxZ( z + 30 ); + + for ( int i = meteorXLength; i < meteorXHeight; i++ ) + for ( int k = meteorZLength; k < meteorZHeight; k++ ) + for ( int j = y - 9; j < y + 30; j++ ) + { + Block blk = w.getBlock( i, j, k ); + if ( blk == Blocks.lava ) + continue; + + if ( blk.isReplaceable( w.getWorld(), i, j, k ) ) + { + blk = Platform.AIR; + Block blk_b = w.getBlock( i, j + 1, k ); + + if ( blk_b != blk ) + { + int meta_b = w.getBlockMetadata( i, j + 1, k ); + + w.setBlock( i, j, k, blk_b, meta_b, 3 ); + w.setBlock( i, j + 1, k, blk ); + } + else if ( randomShit < 100 * this.crater ) + { + double dx = i - x; + double dy = j - y; + double dz = k - z; + double dist = dx * dx + dy * dy + dz * dz; + + Block xf = w.getBlock( i, j - 1, k ); + if ( !xf.isReplaceable( w.getWorld(), i, j - 1, k ) ) + { + double extraRange = Math.random() * 0.6; + double height = this.crater * ( extraRange + 0.2 ) - Math.abs( dist - this.crater * 1.7 ); + + if ( xf != blk && height > 0 && Math.random() > 0.6 ) + { + randomShit++; + this.type.getRandomFall( w, i, j, k ); + } + } + } + } + else + { + // decay. + Block blk_b = w.getBlock( i, j + 1, k ); + if ( blk_b == Platform.AIR ) + { + if ( Math.random() > 0.4 ) + { + double dx = i - x; + double dy = j - y; + double dz = k - z; + + if ( dx * dx + dy * dy + dz * dz < this.crater * 1.6 ) + { + this.type.getRandomInset( w, i, j, k ); + } + } + } + } + } + } + + public double getSqDistance( int x, int z ) + { + int Cx = this.settings.getInteger( "x" ) - x; + int Cz = this.settings.getInteger( "z" ) - z; + + return Cx * Cx + Cz * Cz; + } + + public boolean spawnMeteorite( IMeteoriteWorld w, int x, int y, int z ) + { + int validBlocks = 0; + + if ( !w.hasNoSky() ) + return false; + + Block blk = w.getBlock( x, y, z ); + if ( !this.validSpawn.contains( blk ) ) + return false; // must spawn on a valid block.. + + this.settings = new NBTTagCompound(); + this.settings.setInteger( "x", x ); + this.settings.setInteger( "y", y ); + this.settings.setInteger( "z", z ); + this.settings.setInteger( "blk", Block.getIdFromBlock( blk ) ); + + this.settings.setDouble( "real_sizeOfMeteorite", this.meteoriteSize ); + this.settings.setDouble( "realCrater", this.realCrater ); + this.settings.setDouble( "sizeOfMeteorite", this.squaredMeteoriteSize ); + this.settings.setDouble( "crater", this.crater ); + + this.settings.setBoolean( "lava", Math.random() > 0.9 ); + + if ( blk == Blocks.sand ) + this.type = new FalloutSand( w, x, y, z, this.putter, this.skyStoneDefinition ); + else if ( blk == Blocks.hardened_clay ) + this.type = new FalloutCopy( w, x, y, z, this.putter, this.skyStoneDefinition ); + else if ( blk == Blocks.ice || blk == Blocks.snow ) + this.type = new FalloutSnow( w, x, y, z, this.putter, this.skyStoneDefinition ); + + int realValidBlocks = 0; + + for ( int i = x - 6; i < x + 6; i++ ) + for ( int j = y - 6; j < y + 6; j++ ) + for ( int k = z - 6; k < z + 6; k++ ) + { + blk = w.getBlock( i, j, k ); + if ( this.validSpawn.contains( blk ) ) + realValidBlocks++; + } + + for ( int i = x - 15; i < x + 15; i++ ) + for ( int j = y - 15; j < y + 15; j++ ) + for ( int k = z - 15; k < z + 15; k++ ) + { + blk = w.getBlock( i, j, k ); + if ( this.invalidSpawn.contains( blk ) ) + return false; + if ( this.validSpawn.contains( blk ) ) + validBlocks++; + } + + int minBLocks = 200; + if ( validBlocks > minBLocks && realValidBlocks > 80 ) + { + // we can spawn here! + + int skyMode = 0; + + for ( int i = x - 15; i < x + 15; i++ ) + for ( int j = y - 15; j < y + 11; j++ ) + for ( int k = z - 15; k < z + 15; k++ ) + { + if ( w.canBlockSeeTheSky( i, j, k ) ) + skyMode++; + } + + boolean solid = true; + for ( int j = y - 15; j < y - 1; j++ ) + { + if ( w.getBlock( x, j, z ) == Platform.AIR ) + solid = false; + } + + if ( !solid ) + skyMode = 0; + + // creator + if ( skyMode > 10 ) + this.placeCrater( w, x, y, z ); + + this.placeMeteorite( w, x, y, z ); + + // collapse blocks... + if ( skyMode > 3 ) + this.decay( w, x, y, z ); + + this.settings.setInteger( "skyMode", skyMode ); + w.done(); + + WorldSettings.getInstance().addNearByMeteorites( w.getWorld().provider.dimensionId, x >> 4, z >> 4, this.settings ); + return true; + } + return false; + } + + public NBTTagCompound getSettings() + { + return this.settings; + } + + ; +} diff --git a/src/main/java/appeng/hooks/MeteoriteWorldGen.java b/src/main/java/appeng/worldgen/MeteoriteWorldGen.java similarity index 85% rename from src/main/java/appeng/hooks/MeteoriteWorldGen.java rename to src/main/java/appeng/worldgen/MeteoriteWorldGen.java index e8c81fb87..d519b02ad 100644 --- a/src/main/java/appeng/hooks/MeteoriteWorldGen.java +++ b/src/main/java/appeng/worldgen/MeteoriteWorldGen.java @@ -16,7 +16,8 @@ * along with Applied Energistics 2. If not, see . */ -package appeng.hooks; +package appeng.worldgen; + import java.util.Collection; import java.util.Random; @@ -32,29 +33,12 @@ import appeng.api.features.IWorldGen.WorldGenType; import appeng.core.AEConfig; import appeng.core.WorldSettings; import appeng.core.features.registries.WorldGenRegistry; -import appeng.helpers.MeteoritePlacer; -import appeng.services.compass.ICompassCallback; +import appeng.hooks.TickHandler; import appeng.util.Platform; +import appeng.worldgen.meteorite.ChunkOnly; final public class MeteoriteWorldGen implements IWorldGenerator { - - static class MyGen implements ICompassCallback - { - - double distance = 0; - - @Override - public void calculatedDirection(boolean hasResult, boolean spin, double radians, double dist) - { - if ( hasResult ) - this.distance = dist; - else - this.distance = Double.MAX_VALUE; - } - - } - @Override public void generate(Random r, int chunkX, int chunkZ, World w, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { @@ -103,7 +87,7 @@ final public class MeteoriteWorldGen implements IWorldGenerator for (NBTTagCompound data : MeteoriteWorldGen.this.getNearByMeteorites( this.w, chunkX, chunkZ )) { MeteoritePlacer mp = new MeteoritePlacer(); - mp.spawnMeteorite( new MeteoritePlacer.ChunkOnly( this.w, chunkX, chunkZ ), data ); + mp.spawnMeteorite( new ChunkOnly( this.w, chunkX, chunkZ ), data ); minSqDist = Math.min( minSqDist, mp.getSqDistance( this.x, this.z ) ); } @@ -126,7 +110,7 @@ final public class MeteoriteWorldGen implements IWorldGenerator { MeteoritePlacer mp = new MeteoritePlacer(); - if ( mp.spawnMeteorite( new MeteoritePlacer.ChunkOnly( w, x >> 4, z >> 4 ), x, depth, z ) ) + if ( mp.spawnMeteorite( new ChunkOnly( w, x >> 4, z >> 4 ), x, depth, z ) ) { int px = x >> 4; int pz = z >> 4; @@ -142,7 +126,7 @@ final public class MeteoriteWorldGen implements IWorldGenerator if ( WorldSettings.getInstance().hasGenerated( w.provider.dimensionId, cx, cz ) ) { MeteoritePlacer mp2 = new MeteoritePlacer(); - mp2.spawnMeteorite( new MeteoritePlacer.ChunkOnly( w, cx, cz ), mp.getSettings() ); + mp2.spawnMeteorite( new ChunkOnly( w, cx, cz ), mp.getSettings() ); } } } diff --git a/src/main/java/appeng/hooks/QuartzWorldGen.java b/src/main/java/appeng/worldgen/QuartzWorldGen.java similarity index 69% rename from src/main/java/appeng/hooks/QuartzWorldGen.java rename to src/main/java/appeng/worldgen/QuartzWorldGen.java index 068c6f26b..399e3ea20 100644 --- a/src/main/java/appeng/hooks/QuartzWorldGen.java +++ b/src/main/java/appeng/worldgen/QuartzWorldGen.java @@ -16,7 +16,8 @@ * along with Applied Energistics 2. If not, see . */ -package appeng.hooks; +package appeng.worldgen; + import java.util.Random; @@ -29,38 +30,40 @@ import net.minecraft.world.gen.feature.WorldGenMinable; import cpw.mods.fml.common.IWorldGenerator; import appeng.api.AEApi; +import appeng.api.definitions.IBlockDefinition; +import appeng.api.definitions.IBlocks; import appeng.api.features.IWorldGen.WorldGenType; import appeng.core.AEConfig; import appeng.core.features.registries.WorldGenRegistry; + final public class QuartzWorldGen implements IWorldGenerator { + private final WorldGenMinable oreNormal; + private final WorldGenMinable oreCharged; - final WorldGenMinable oreNormal; - final WorldGenMinable oreCharged; + public QuartzWorldGen() + { + final IBlocks blocks = AEApi.instance().definitions().blocks(); + final IBlockDefinition oreDefinition = blocks.quartzOre(); + final IBlockDefinition chargedDefinition = blocks.quartzOreCharged(); - public QuartzWorldGen() { - Block normal = AEApi.instance().blocks().blockQuartzOre.block(); - Block charged = AEApi.instance().blocks().blockQuartzOreCharged.block(); + final Block ore = oreDefinition.maybeBlock().orNull(); + final Block charged = chargedDefinition.maybeBlock().orNull(); - if ( normal != null && charged != null ) - { - this.oreNormal = new WorldGenMinable( normal, 0, AEConfig.instance.quartzOresPerCluster, Blocks.stone ); - this.oreCharged = new WorldGenMinable( charged, 0, AEConfig.instance.quartzOresPerCluster, Blocks.stone ); - } - else - this.oreNormal = this.oreCharged = null; + this.oreNormal = new WorldGenMinable( ore, 0, AEConfig.instance.quartzOresPerCluster, Blocks.stone ); + this.oreCharged = new WorldGenMinable( charged, 0, AEConfig.instance.quartzOresPerCluster, Blocks.stone ); } @Override - public void generate(Random r, int chunkX, int chunkZ, World w, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) + public void generate( Random r, int chunkX, int chunkZ, World w, IChunkProvider chunkGenerator, IChunkProvider chunkProvider ) { int seaLevel = w.provider.getAverageGroundLevel() + 1; if ( seaLevel < 20 ) { - int x = (chunkX << 4) + 8; - int z = (chunkZ << 4) + 8; + int x = ( chunkX << 4 ) + 8; + int z = ( chunkZ << 4 ) + 8; seaLevel = w.getHeightValue( x, z ); } @@ -70,7 +73,7 @@ final public class QuartzWorldGen implements IWorldGenerator double oreDepthMultiplier = AEConfig.instance.quartzOresClusterAmount * seaLevel / 64; int scale = (int) Math.round( r.nextGaussian() * Math.sqrt( oreDepthMultiplier ) + oreDepthMultiplier ); - for (int x = 0; x < (r.nextBoolean() ? scale * 2 : scale) / 2; ++x) + for ( int x = 0; x < ( r.nextBoolean() ? scale * 2 : scale ) / 2; ++x ) { boolean isCharged = r.nextFloat() > AEConfig.instance.spawnChargedChance; WorldGenMinable whichOre = isCharged ? this.oreCharged : this.oreNormal; @@ -83,6 +86,5 @@ final public class QuartzWorldGen implements IWorldGenerator whichOre.generate( w, r, cx, cy, cz ); } } - } } diff --git a/src/main/java/appeng/worldgen/meteorite/ChunkOnly.java b/src/main/java/appeng/worldgen/meteorite/ChunkOnly.java new file mode 100644 index 000000000..f2484f192 --- /dev/null +++ b/src/main/java/appeng/worldgen/meteorite/ChunkOnly.java @@ -0,0 +1,98 @@ +package appeng.worldgen.meteorite; + + +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; + +import appeng.util.Platform; + + +public class ChunkOnly extends StandardWorld +{ + + final Chunk target; + final int cx, cz; + int verticalBits = 0; + + public ChunkOnly( World w, int cx, int cz ) + { + super( w ); + this.target = w.getChunkFromChunkCoords( cx, cz ); + this.cx = cx; + this.cz = cz; + } + + @Override + public int minX( int in ) + { + return Math.max( in, this.cx << 4 ); + } + + @Override + public int minZ( int in ) + { + return Math.max( in, this.cz << 4 ); + } + + @Override + public int maxX( int in ) + { + return Math.min( in, ( this.cx + 1 ) << 4 ); + } + + @Override + public int maxZ( int in ) + { + return Math.min( in, ( this.cz + 1 ) << 4 ); + } + + @Override + public int getBlockMetadata( int x, int y, int z ) + { + if ( this.range( x, y, z ) ) + return this.target.getBlockMetadata( x & 0xF, y, z & 0xF ); + return 0; + } + + @Override + public Block getBlock( int x, int y, int z ) + { + if ( this.range( x, y, z ) ) + return this.target.getBlock( x & 0xF, y, z & 0xF ); + return Platform.AIR; + } + + @Override + public void setBlock( int x, int y, int z, Block blk ) + { + if ( this.range( x, y, z ) ) + { + this.verticalBits |= 1 << ( y >> 4 ); + this.w.setBlock( x, y, z, blk, 0, 1 ); + } + } + + @Override + public void setBlock( int x, int y, int z, Block blk, int metadata, int flags ) + { + if ( this.range( x, y, z ) ) + { + this.verticalBits |= 1 << ( y >> 4 ); + this.w.setBlock( x, y, z, blk, metadata, flags & ( ~2 ) ); + } + } + + @Override + public void done() + { + if ( this.verticalBits != 0 ) + Platform.sendChunk( this.target, this.verticalBits ); + } + + @Override + public boolean range( int x, int y, int z ) + { + return this.cx == ( x >> 4 ) && this.cz == ( z >> 4 ); + } +} diff --git a/src/main/java/appeng/worldgen/meteorite/Fallout.java b/src/main/java/appeng/worldgen/meteorite/Fallout.java new file mode 100644 index 000000000..de5c5e263 --- /dev/null +++ b/src/main/java/appeng/worldgen/meteorite/Fallout.java @@ -0,0 +1,61 @@ +package appeng.worldgen.meteorite; + + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; + +import appeng.api.definitions.IBlockDefinition; +import appeng.util.Platform; + + +public class Fallout +{ + private final MeteoriteBlockPutter putter; + private final IBlockDefinition skyStoneDefinition; + + public Fallout( MeteoriteBlockPutter putter, IBlockDefinition skyStoneDefinition ) + { + this.putter = putter; + this.skyStoneDefinition = skyStoneDefinition; + } + + public int adjustCrater() + { + return 0; + } + + public void getRandomFall( IMeteoriteWorld w, int x, int y, int z ) + { + double a = Math.random(); + if ( a > 0.9 ) + this.putter.put( w, x, y, z, Blocks.stone ); + else if ( a > 0.8 ) + this.putter.put( w, x, y, z, Blocks.cobblestone ); + else if ( a > 0.7 ) + this.putter.put( w, x, y, z, Blocks.dirt ); + else + this.putter.put( w, x, y, z, Blocks.gravel ); + } + + public void getRandomInset( IMeteoriteWorld w, int x, int y, int z ) + { + double a = Math.random(); + if ( a > 0.9 ) + this.putter.put( w, x, y, z, Blocks.cobblestone ); + else if ( a > 0.8 ) + this.putter.put( w, x, y, z, Blocks.stone ); + else if ( a > 0.7 ) + this.putter.put( w, x, y, z, Blocks.grass ); + else if ( a > 0.6 ) + { + for ( Block skyStoneBlock : this.skyStoneDefinition.maybeBlock().asSet() ) + { + this.putter.put( w, x, y, z, skyStoneBlock ); + } + } + else if ( a > 0.5 ) + this.putter.put( w, x, y, z, Blocks.gravel ); + else + this.putter.put( w, x, y, z, Platform.AIR ); + } +} diff --git a/src/main/java/appeng/worldgen/meteorite/FalloutCopy.java b/src/main/java/appeng/worldgen/meteorite/FalloutCopy.java new file mode 100644 index 000000000..1c0ac84c3 --- /dev/null +++ b/src/main/java/appeng/worldgen/meteorite/FalloutCopy.java @@ -0,0 +1,64 @@ +package appeng.worldgen.meteorite; + + +import net.minecraft.block.Block; + +import appeng.api.definitions.IBlockDefinition; +import appeng.util.Platform; + + +public class FalloutCopy extends Fallout +{ + public static final double SPECIFIED_BLOCK_THRESHOLD = 0.9; + public static final double AIR_BLOCK_THRESHOLD = 0.8; + public static final double BLOCK_THRESHOLD_STEP = 0.1; + + private final Block block; + private final int meta; + private final MeteoriteBlockPutter putter; + + public FalloutCopy( IMeteoriteWorld w, int x, int y, int z, MeteoriteBlockPutter putter, IBlockDefinition skyStoneDefinition ) + { + super( putter, skyStoneDefinition ); + this.putter = putter; + this.block = w.getBlock( x, y, z ); + this.meta = w.getBlockMetadata( x, y, z ); + } + + @Override + public void getRandomFall( IMeteoriteWorld w, int x, int y, int z ) + { + double a = Math.random(); + if ( a > SPECIFIED_BLOCK_THRESHOLD ) + { + this.putter.put( w, x, y, z, this.block, this.meta ); + } + else + { + this.getOther( w, x, y, z, a ); + } + } + + public void getOther( IMeteoriteWorld w, int x, int y, int z, double a ) + { + + } + + @Override + public void getRandomInset( IMeteoriteWorld w, int x, int y, int z ) + { + double a = Math.random(); + if ( a > SPECIFIED_BLOCK_THRESHOLD ) + { + this.putter.put( w, x, y, z, this.block, this.meta ); + } + else if ( a > AIR_BLOCK_THRESHOLD ) + { + this.putter.put( w, x, y, z, Platform.AIR ); + } + else + { + this.getOther( w, x, y, z, a - BLOCK_THRESHOLD_STEP ); + } + } +} \ No newline at end of file diff --git a/src/main/java/appeng/worldgen/meteorite/FalloutSand.java b/src/main/java/appeng/worldgen/meteorite/FalloutSand.java new file mode 100644 index 000000000..869dc9a08 --- /dev/null +++ b/src/main/java/appeng/worldgen/meteorite/FalloutSand.java @@ -0,0 +1,32 @@ +package appeng.worldgen.meteorite; + + +import net.minecraft.init.Blocks; + +import appeng.api.definitions.IBlockDefinition; + + +public class FalloutSand extends FalloutCopy +{ + public static final double GLASS_THRESHOLD = 0.66; + private final MeteoriteBlockPutter putter; + + public FalloutSand( IMeteoriteWorld w, int x, int y, int z, MeteoriteBlockPutter putter, IBlockDefinition skyStoneDefinition ) + { + super( w, x, y, z, putter, skyStoneDefinition ); + this.putter = putter; + } + + @Override + public int adjustCrater() + { + return 2; + } + + @Override + public void getOther( IMeteoriteWorld w, int x, int y, int z, double a ) + { + if ( a > GLASS_THRESHOLD ) + this.putter.put( w, x, y, z, Blocks.glass ); + } +} \ No newline at end of file diff --git a/src/main/java/appeng/worldgen/meteorite/FalloutSnow.java b/src/main/java/appeng/worldgen/meteorite/FalloutSnow.java new file mode 100644 index 000000000..173b5f801 --- /dev/null +++ b/src/main/java/appeng/worldgen/meteorite/FalloutSnow.java @@ -0,0 +1,39 @@ +package appeng.worldgen.meteorite; + + +import net.minecraft.init.Blocks; + +import appeng.api.definitions.IBlockDefinition; + + +public class FalloutSnow extends FalloutCopy +{ + public static final double SNOW_THRESHOLD = 0.7; + public static final double ICE_THRESHOLD = 0.5; + private final MeteoriteBlockPutter putter; + + public FalloutSnow( IMeteoriteWorld w, int x, int y, int z, MeteoriteBlockPutter putter, IBlockDefinition skyStoneDefinition ) + { + super( w, x, y, z, putter, skyStoneDefinition ); + this.putter = putter; + } + + @Override + public int adjustCrater() + { + return 2; + } + + @Override + public void getOther( IMeteoriteWorld w, int x, int y, int z, double a ) + { + if ( a > SNOW_THRESHOLD ) + { + this.putter.put( w, x, y, z, Blocks.snow ); + } + else if ( a > ICE_THRESHOLD ) + { + this.putter.put( w, x, y, z, Blocks.ice ); + } + } +} \ No newline at end of file diff --git a/src/main/java/appeng/worldgen/meteorite/IMeteoriteWorld.java b/src/main/java/appeng/worldgen/meteorite/IMeteoriteWorld.java new file mode 100644 index 000000000..7a42bb442 --- /dev/null +++ b/src/main/java/appeng/worldgen/meteorite/IMeteoriteWorld.java @@ -0,0 +1,36 @@ +package appeng.worldgen.meteorite; + + +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + + +public interface IMeteoriteWorld +{ + int minX( int in ); + + int minZ( int in ); + + int maxX( int in ); + + int maxZ( int in ); + + boolean hasNoSky(); + + int getBlockMetadata( int x, int y, int z ); + + Block getBlock( int x, int y, int z ); + + boolean canBlockSeeTheSky( int i, int j, int k ); + + TileEntity getTileEntity( int x, int y, int z ); + + World getWorld(); + + void setBlock( int i, int j, int k, Block blk ); + + void setBlock( int i, int j, int k, Block blk_b, int meta_b, int l ); + + void done(); +} \ No newline at end of file diff --git a/src/main/java/appeng/worldgen/meteorite/MeteoriteBlockPutter.java b/src/main/java/appeng/worldgen/meteorite/MeteoriteBlockPutter.java new file mode 100644 index 000000000..6bb4a726d --- /dev/null +++ b/src/main/java/appeng/worldgen/meteorite/MeteoriteBlockPutter.java @@ -0,0 +1,30 @@ +package appeng.worldgen.meteorite; + + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; + + +public class MeteoriteBlockPutter +{ + public boolean put( IMeteoriteWorld w, int i, int j, int k, Block blk ) + { + Block original = w.getBlock( i, j, k ); + + if ( original == Blocks.bedrock || original == blk ) + return false; + + w.setBlock( i, j, k, blk ); + return true; + } + + public void put( IMeteoriteWorld w, int i, int j, int k, Block blk, int meta ) + { + if ( w.getBlock( i, j, k ) == Blocks.bedrock ) + { + return; + } + + w.setBlock( i, j, k, blk, meta, 3 ); + } +} diff --git a/src/main/java/appeng/worldgen/meteorite/StandardWorld.java b/src/main/java/appeng/worldgen/meteorite/StandardWorld.java new file mode 100644 index 000000000..6656c4efc --- /dev/null +++ b/src/main/java/appeng/worldgen/meteorite/StandardWorld.java @@ -0,0 +1,113 @@ +package appeng.worldgen.meteorite; + + +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import appeng.util.Platform; + + +public class StandardWorld implements IMeteoriteWorld +{ + + protected final World w; + + public StandardWorld( World w ) + { + this.w = w; + } + + @Override + public int minX( int in ) + { + return in; + } + + @Override + public int minZ( int in ) + { + return in; + } + + @Override + public int maxX( int in ) + { + return in; + } + + @Override + public int maxZ( int in ) + { + return in; + } + + @Override + public boolean hasNoSky() + { + return !this.w.provider.hasNoSky; + } + + @Override + public int getBlockMetadata( int x, int y, int z ) + { + if ( this.range( x, y, z ) ) + return this.w.getBlockMetadata( x, y, z ); + return 0; + } + + @Override + public Block getBlock( int x, int y, int z ) + { + if ( this.range( x, y, z ) ) + return this.w.getBlock( x, y, z ); + return Platform.AIR; + } + + @Override + public boolean canBlockSeeTheSky( int x, int y, int z ) + { + if ( this.range( x, y, z ) ) + return this.w.canBlockSeeTheSky( x, y, z ); + return false; + } + + @Override + public TileEntity getTileEntity( int x, int y, int z ) + { + if ( this.range( x, y, z ) ) + return this.w.getTileEntity( x, y, z ); + return null; + } + + @Override + public World getWorld() + { + return this.w; + } + + @Override + public void setBlock( int x, int y, int z, Block blk ) + { + if ( this.range( x, y, z ) ) + this.w.setBlock( x, y, z, blk ); + } + + @Override + public void setBlock( int x, int y, int z, Block blk, int metadata, int flags ) + { + if ( this.range( x, y, z ) ) + this.w.setBlock( x, y, z, blk, metadata, flags ); + } + + @Override + public void done() + { + + } + + public boolean range( int x, int y, int z ) + { + return true; + } +}